我正在调试GULP文件中的一个错误。我似乎不知道应该更改什么。错误如下:
将自动前缀浏览器选项替换为Browserslist配置请使用package.json或.browserslistrc文件中browserslist键
使用浏览器选项会导致一些错误。浏览器列表配置可用于Babel、自动前缀器、postcss-normalize和其他工具。
如果确实需要使用该选项,请将其重命名为overrideBrowserslist。
如欲了解更多信息,请访问:https://github.com/browserslist/browserslist#readme:
[12:20:01]以下任务未完成:default,compile-scss [12:20:01]您是否忘记发出异步完成信号?
var gulp = require('gulp');
// Include plugins
var path = require('path');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');
var folders = require('gulp-folders');
var imagemin = require('gulp-imagemin');
// Config
var inputFolders = 'src'
var outputFolders = 'public'
var scssInput = 'styles';
var scssOutput = 'styles'
var jsInput = 'scripts';
var jsOutput = 'scripts';
var mediaInput = 'images';
var mediaOutput = 'images';
var backupImageFolder = 'backup-image';
// compile scss into css
gulp.task('compile-scss', folders(inputFolders, function (folder) {
var processors = [
autoprefixer({browsers: ['last 2 versions', 'IE 10', 'Safari 8']})
];
return gulp.src(inputFolders + '/' + folder + '/' + scssInput + '/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss(processors))
.pipe(cleanCSS({compatibility:'*'}))
.pipe(gulp.dest(outputFolders + '/' + folder + '/' + scssOutput));
}));
// concatenate and minify js
gulp.task('scripts', folders(inputFolders, function(folder) {
return gulp.src(inputFolders + '/' + folder + '/' + jsInput + '/*.js')
// .pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest(outputFolders + '/' + folder + '/' + jsOutput));
}));
// deploy any media and losslessly optimise if possible
gulp.task('media', folders(inputFolders, function(folder) {
return gulp.src([inputFolders + '/' + folder + '/' + mediaInput + '/*', inputFolders + '/' + folder + '/' + mediaInput + '/**/*'])
.pipe(imagemin())
.pipe(gulp.dest(outputFolders + '/' + folder + '/' + mediaOutput));
}));
// copy across html
gulp.task('html', folders(inputFolders, function(folder) {
return gulp.src(inputFolders + '/' + folder + '/*.html')
.pipe(gulp.dest(outputFolders + '/' + folder))
}));
// copy across back-up image for the banner
gulp.task('copy-backup-image', folders(inputFolders, function(folder) {
return gulp.src(inputFolders + '/' + folder + '/' + backupImageFolder + '/*' )
.pipe(gulp.dest(outputFolders + '/' + folder + '/' + backupImageFolder))
}));
// Watch files for changes, run affected tasks
gulp.task('watch', function() {
gulp.watch([inputFolders + '/*/' + scssInput + '/*.scss'], gulp.series('compile-scss'));
gulp.watch([inputFolders + '/*/' + scssInput + '/**/*.scss'], gulp.series('compile-scss'));
gulp.watch([inputFolders + '/*/' + jsInput + '/*.js'], gulp.series('scripts'));
gulp.watch([inputFolders + '/*/' + mediaInput + '/*'], gulp.series('media'));
gulp.watch([inputFolders + '/*/' + mediaInput + '/**/*'], gulp.series('media'));
gulp.watch([inputFolders + '/*/*.html'], gulp.series('html'));
gulp.watch([inputFolders + '/*/' + backupImageFolder + '/*'], gulp.series('copy-backup-image'));
});
// Default task
gulp.task('default',
gulp.series(gulp.parallel('compile-scss', 'scripts', 'media', 'html', 'copy-backup-image'), 'watch'));
2条答案
按热度按时间whlutmcx1#
在工作根目录或工作区目录中创建一个
.browserslistrc
,其中包含如下内容:然后更改此代码:
var processors = [ autoprefixer({browsers: ['last 2 versions', 'IE 10', 'Safari 8']}) ];
只需:
var processors = [ autoprefixer() ];
这应该可以消除对
browsers
选项的抱怨。然后运行您的default
任务,看看是否修复了您的'compile-scss'
无法完成错误消息并返回报告。现在对于异步信号问题。那个
gulp-folders
插件已经5年没有更新了,所以我建议换一种方法。b4qexyjb2#
下面的解决方案为我工作,你必须添加下面的详细信息到您的package.json文件.并删除在autoprefixer中提到的浏览器.我希望这将工作.