具有以下 gulp 文件:
var gulp = require("gulp");
var args = require("yargs").argv;
var config = require("./gulp.config")();
var del = require("del");
var $ = require("gulp-load-plugins")({ lazy: true });
gulp.task("styles", ["clean-styles"], function() {
log("Compiling SASS ---> CSS");
return gulp
.src(config.sass)
.pipe($.plumber())
.pipe($.sass())
.pipe($.autoprefixer({ browsers: ["last 2 version", "> 5%"] }))
.pipe(gulp.dest(config.temp));
});
gulp.task("clean-styles", function(done) {
var files = config.temp + "**/*.css";
clean(files, done);
});
gulp.task("sass-watcher", function() {
gulp.watch([config.sass], ["styles"]);
});
function clean(path, done) {
log("Cleaning: " + $.util.colors.yellow(path));
del(path, done);
};
function log(msg) {
if (typeof (msg) == "object") {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.yellow(msg[item]));
}
}
} else {
$.util.log($.util.colors.yellow(msg));
}
};
问题是sass-watcher
没有完成任务,这就是gulp-plumber
我相信的全部意义。
当sass
文件中出现编译错误时,使用此配置停止流,并提供最少的错误信息:
如果我更改配置以注意 sass 选项的差异:
return gulp
.src(config.sass)
.pipe($.plumber())
.pipe($.sass({ errLogToConsole: true }))
.pipe($.autoprefixer({ browsers: ["last 2 version", "> 5%"] }))
.pipe(gulp.dest(config.temp));
任务已正确完成,我收到以下错误消息:
[15:50:22] [gulp-sass] error reading values after 10px on line 23 in C:/Projects/ProjectName/sass/bootstrap-custom.scss
我希望错误被处理gulp-plumber
,任何想法为什么它不能很好玩gulp-sass
?
顺便说一句,我在 Windows 机器上并使用cmd prompt