概述
最近在配置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
在網(wǎng)上查找資料發(fā)現(xiàn):是因為版本太高的原因簿晓,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'));
});