var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('default', () => {
return new Promise(function (resolve, reject) {
console.log("HTTP Server Started");
resolve();
});
});
gulp.task('sass', () => {
return new Promise(function (resolve, reject) {
gulp.src('scss/*'.scss)//待编译文件
.pipe(sass())//sass转css方法
.pipe(pulp.dest('css'))//输出文件路径
resolve();
});
});
gulp.task('watch', () => {
return new Promise(function (resolve, reject) {
gulp.watch('./scss/*.scss', ['sass'])//watch监听文件
resolve();
});
})
当运行 gulp watch时:
直接报错:Error: watching ./scss/*.scss: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
现在使用的gulp4.0 版本,watch的第二个参数是函数,所以要修改gulpfile.js:
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('default', () => {
return new Promise(function (resolve, reject) {
console.log("HTTP Server Started");
resolve();
});
});
gulp.task('sass', () => {
return new Promise(function (resolve, reject) {
gulp.src('scss/*'.scss)//待编译文件
.pipe(sass())//sass转css方法
.pipe(pulp.dest('css'))//输出文件路径
resolve();
});
});
gulp.task('watch', () => {
return new Promise(function (resolve, reject) {
gulp.watch('./scss/*.scss', gulp.series('sass'))//watch监听文件
resolve();
});
})
转载于:Zero Ice
https://blog.csdn.net/weixin_41593408/article/details/86860079