当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript postcss.default函数代码示例

本文整理汇总了TypeScript中postcss.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: compileStyle

export function compileStyle (
  options: StyleCompileOptions
): StyleCompileResults {
  const {
    filename,
    id,
    scoped = true,
    trim = true,
    preprocessLang,
    postcssOptions,
    postcssPlugins
  } = options
  const preprocessor = preprocessLang && processors[preprocessLang]
  const preProcessedSource = preprocessor && preprocess(options, preprocessor)
  const map = preProcessedSource ? preProcessedSource.map : options.map
  const source = preProcessedSource ? preProcessedSource.code : options.source

  const plugins = (postcssPlugins || []).slice()
  if (trim) {
    plugins.push(trimPlugin())
  }
  if (scoped) {
    plugins.push(scopedPlugin(id))
  }

  const postCSSOptions: ProcessOptions = {
    ...postcssOptions,
    to: filename,
    from: filename
  }
  if (map) {
    postCSSOptions.map = {
      inline: false,
      annotation: false,
      prev: map
    }
  }

  let result, code, outMap
  const errors = []
  if (preProcessedSource && preProcessedSource.errors.length) {
    errors.push(...preProcessedSource.errors)
  }
  try {
    result = postcss(plugins).process(source, postCSSOptions)
    // force synchronous transform (we know we only have sync plugins)
    code = result.css
    outMap = result.map
  } catch (e) {
    errors.push(e)
  }

  return {
    code: code || ``,
    map: outMap && outMap.toJSON(),
    errors,
    rawResult: result
  }
}
开发者ID:gilFuser,项目名称:gilFuser.github.io,代码行数:59,代码来源:compileStyle.ts

示例2: postcss

var test = (input: string, output: string, opts: Object, done: Function) => {
    postcss([processor(opts)]).process(input).then((result) => {
        expect(result.css).to.eql(output);
        expect(result.warnings()).to.be.empty;
        done();
    }).catch((error) => {
        done(error);
    });
};
开发者ID:furny,项目名称:postcss-mm,代码行数:9,代码来源:index.spec.ts

示例3: generateCss

async function generateCss(): Promise<void> {
  const cssInPath = path.resolve(INPUT_DIR, "ui/css/app.css");
  const cssOutPath = path.resolve(OUTPUT_DIR, "public/app.css");
  const cssIn = fs.readFileSync(cssInPath);
  const cssOut = await postcss([
    postcssImport,
    postcssCssNext({ warnForDuplicates: false }),
    cssnano
  ]).process(cssIn, { from: cssInPath, to: cssOutPath });
  fs.writeFileSync(cssOutPath, cssOut.css);
}
开发者ID:zaidka,项目名称:genieacs,代码行数:11,代码来源:build.ts

示例4: _compileSCSS

  /**
   * Compiles SCSS to CSS and passes it through Autoprefixer.
   */
  static _compileSCSS(styles: string): string {
    let compiled = sass.renderSync({
      data: styles,
      outputStyle: 'compressed'
    }).css.toString();


    let prefixer = autoprefixer({
      browsers: ['last 2 versions', 'last 4 Android versions']
    });

    return postcss(prefixer).process(compiled).css;
  }
开发者ID:angular,项目名称:material-tools,代码行数:16,代码来源:CSSBuilder.ts

示例5: postcss

 render.then((css: string) => postcss([ autoprefixer({ browsers }) ]).process(css))
开发者ID:davidenke,项目名称:ng-packagr,代码行数:1,代码来源:assets.ts

示例6: postcss

 .map((file) => postcss(postCssPlugins)
     .process(file.content, {
         from: file.scssFile,
         to: file.cssFile
     })
开发者ID:dfbaskin,项目名称:angular2-overview,代码行数:5,代码来源:build-css.ts

示例7: check

function check(input: string, output: string) {
	const processor = postcss([plugin()]);
	expect(processor.process(input).css).to.equal(output);
}
开发者ID:cybernetics,项目名称:postcss-nested-props,代码行数:4,代码来源:plugin.ts

示例8: doCompileStyle

export function doCompileStyle(
  options: AsyncStyleCompileOptions
): StyleCompileResults {
  const {
    filename,
    id,
    scoped = true,
    trim = true,
    preprocessLang,
    postcssOptions,
    postcssPlugins
  } = options
  const preprocessor = preprocessLang && processors[preprocessLang]
  const preProcessedSource = preprocessor && preprocess(options, preprocessor)
  const map = preProcessedSource ? preProcessedSource.map : options.map
  const source = preProcessedSource ? preProcessedSource.code : options.source

  const plugins = (postcssPlugins || []).slice()
  if (trim) {
    plugins.push(trimPlugin())
  }
  if (scoped) {
    plugins.push(scopedPlugin(id))
  }

  const postCSSOptions: ProcessOptions = {
    ...postcssOptions,
    to: filename,
    from: filename
  }
  if (map) {
    postCSSOptions.map = {
      inline: false,
      annotation: false,
      prev: map
    }
  }

  let result, code, outMap
  const errors: any[] = []
  if (preProcessedSource && preProcessedSource.errors.length) {
    errors.push(...preProcessedSource.errors)
  }
  try {
    result = postcss(plugins).process(source, postCSSOptions)

    // In async mode, return a promise.
    if (options.isAsync) {
      return result
        .then(
          (result: LazyResult): StyleCompileResults => ({
            code: result.css || '',
            map: result.map && result.map.toJSON(),
            errors,
            rawResult: result
          })
        )
        .catch(
          (error: Error): StyleCompileResults => ({
            code: '',
            map: undefined,
            errors: [...errors, error.message],
            rawResult: undefined
          })
        )
    }

    // force synchronous transform (we know we only have sync plugins)
    code = result.css
    outMap = result.map
  } catch (e) {
    errors.push(e)
  }

  return {
    code: code || ``,
    map: outMap && outMap.toJSON(),
    errors,
    rawResult: result
  }
}
开发者ID:aldCom,项目名称:aldCom.github.io,代码行数:81,代码来源:compileStyle.ts


注:本文中的postcss.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。