How to use the autoprefixer.process function in autoprefixer

To help you get started, we’ve selected a few autoprefixer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oklai / koala / src / app / scripts / compilers / LessCompiler.js View on Github external
var saveCss = function (css) {
        // remove local file path prefix
        if (settings.lineComments || settings.debugInfo) {
            var rootDir = options.paths[0] + path.sep;
                rootDir = rootDir.replace(/\\/g, '\\\\');
            css = css.replace(new RegExp(rootDir, 'g'), '');
        }

        // auto add css prefix
        if (settings.autoprefix) {
            css = require('autoprefixer').process(css).css;
            if (settings.sourceMap) {
                css = css + '\n/*# sourceMappingURL=' + path.basename(output) + '.map */'
            }
        }

        //write css code into output
        fs.writeFile(output, css, 'utf8', function (wErr) {
            if (wErr) {
                triggerError(wErr);
            } else {
                emitter.emit('done');
                emitter.emit('always');

                //add watch import file
                common.watchImports('less', filePath);
            }
github axa-ch / patterns-library / stack / tasks / build-examples.js View on Github external
const name = _filePath.split('/').slice(-2).join('/');
    const previewName = name.replace('/_preview.html', '');

    const example = fs.readFileSync(exampleHtmls[index], 'utf8');
    const preview = fs.readFileSync(_filePath, 'utf8');

    let resultCss;
    let resultCssString;

    try {
      resultCss = sass.renderSync({
        file: _filePath.replace('_preview.html', 'index.scss'),
        outputStyle: 'expanded',
      });
      resultCssString = autoprefixer.process(resultCss.css).css;
    } catch (error) {} // eslint-disable-line

    switch (previewName.substring(0, 2)) {
      case 'a-':
        createAmoComponents(ATOMS, previewName, 'Atom', preview, resultCssString, example);
        break;
      case 'm-':
        createAmoComponents(MOLECULES, previewName, 'Molecule', preview, resultCssString, example);
        break;
      case 'o-':
        createAmoComponents(ORGANISMS, previewName, 'Organism', preview, resultCssString, example);
        break;
      default:
        createAmoComponents(ORGANISMS, previewName, 'Organism', preview, resultCssString, example);
    }
  });
github olback / es6-css-minify / src / css.ts View on Github external
minify(_input: string | CssInputFile): MinifyOutput {

        const cssInputStr = typeof _input === 'string' ? _input : _input.data;

        let css: string;

        if (this.ap.use) {

            try {

                css = autoprefixer.process(cssInputStr, this.ap.options).toString();

            } catch (e) {

                return {
                    success: false,
                    warnings: [],
                    errors: [
                        // 'Autoprefixer failed to parse CSS. Probaly due to an syntax error.',
                         e.message
                    ]
                };

            }

        } else {
github sinnerschrader / ranger / tasks / configuration / less.js View on Github external
less.render(data.toString('utf-8'), lessOptions, (err, css) => {
      if (err) throw err
      let results = autoprefixer.process(css.css).css

      fs.writeFile(cssFile, results, 'utf-8', (err) => {
        if (err) throw err
        console.log('CSS was successfully generated')
      })
    })
github oklai / koala / src / app / scripts / compilers / common.js View on Github external
exports.autoprefix = function (file) {
    var cssFile = file.output,
        css = fs.readFileSync(cssFile),
        autoprefixer = require('autoprefixer');

    css = autoprefixer.process(css).css;

    if (file.settings.sourceMap) {
        css = css + '\n/*# sourceMappingURL=' + path.basename(cssFile) + '.map */'
    }

    fs.writeFileSync(cssFile, css);
}
github gdotdesign / elm-dev-env / bin / lib / render / css.js View on Github external
sass.render({ file: file }, function (err, result) {
      if (err) {
        var prettyError =
          renderError('You have errors in of your Sass file(s):', err.formatted)

        if (shouldFail) {
          callback(err.formatted, null)
        } else {
          callback(null, prettyError)
        }
      } else {
        autoprefixer
          .process(result.css)
          .then(function (result2) {
            callback(null, result2.css)
          })
      }
    })
  }
github hivewallet / hive-ios / tasks.js View on Github external
success: function(css){
        var prefixed = autoprefixer.process(css).css
        fs.writeFile(outFile, prefixed, cb)
      },
      error: cb
github kerrishotts / Mastering-PhoneGap-Code-Package / snippets / index.js View on Github external
Sass.compile(scssText, function (r) {
                if (scssText.substr(0,5) === "//!NA") {
                    cssEditor.setValue(r.text, -1);
                } else {
                    cssEditor.setValue(autoprefixer.process(r.text).css, -1);
                }
            });
        }