Reputation: 1442
I am trying to add Autoprefixer into a Node.js script I have which compiles my SCSS files. On the Autoprefixer docs on npm.js.com they give the following code example for use with Node:
var autoprefixer = require('autoprefixer');
var postcss = require('postcss');
postcss([ autoprefixer ]).process(css).then(function (result) {
result.warnings().forEach(function (warn) {
console.warn(warn.toString());
});
console.log(result.css);
});
After implementing this my CSS is still returning without browser prefixes having been added. I believe this is because I have not passed in which browsers I wish to support. When I've used Autoprefixer in the past you have to pass a string such as 'last 2 versions' for this purpose. However I can't seem to find any documentation which shows how I can do this using Autoprefixer in this way. Can anyone help? Thanks
Upvotes: 1
Views: 1328
Reputation: 10419
The currently recommended ways of defining supported browser are:
.browserslistrc
config file in the project rootbrowserslist
field in project's package.json
filebrowsers
option is still supported, but it's use is discouraged:
postcss([ autoprefixer({ browsers: 'last 2 versions' }) ])
Upvotes: 0