概述
最近在配置gulp-autoprefixer时,控制台报出警告:
Replace Autoprefixer browsers option to Browserslist config.
Use browserslist key in package.json or .browserslistrc file.
Using browsers option cause some error. Browserslist config
can be used for Babel, Autoprefixer, postcss-normalize and other tools.
If you really need to use option, rename it to overrideBrowserslist.
Learn more at:
https://github.com/browserslist/browserslist#readme
https://twitter.com/browserslist
在网上查找资料发现:是因为版本太高的原因,5.0.0版本以后的API有修改。
解决方案
1.指定安装5.0.0版本,"gulp-autoprefixer": "5.0.0"
gulp.task('css', function () {
return gulp.src('css/*.css').
pipe(autoprefixer({
browsers: ['last 2 versions', 'Android >= 4.0']
})).
pipe(gulp.dest('dist/css'));
});
2.将browsers
重命名为overrideBrowserslist
gulp.task('css', function () {
return gulp.src('css/*.css').
pipe(autoprefixer({
overrideBrowserslist: ['last 2 versions', 'Android >= 4.0']
})).
pipe(gulp.dest('dist/css'));
});