我有 gulp watch 的问题。 在我第一次调用它之后,在我对sass文件进行更改之后,终端没有任何更改。只有当我重新调用gulp-watch时,才会看到样式的变化。 我的gulpfile.js看起来像这样:
'use strict'
var gulp = require('gulp');
var sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
autoprefixer = require('gulp-autoprefixer'),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
watch = require('gulp-watch');
gulp.task('html', function() {
return gulp.src('assets/*.html')
.pipe(gulp.dest('public'));
});
gulp.task('sass', function() {
return gulp.src('assets/css/main.scss')
.pipe(sass())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(cssnano())
.pipe(gulp.dest("public/css"));
})
gulp.task('scripts', function() {
return gulp.src('assets/javascript/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('public/javascript'));
})
gulp.task('imgs', function() {
return gulp.src("assets/images/*.+(jpg|jpeg|png|gif)")
.pipe(imagemin({
progressive: true,
svgoPlugins: [{ removeViewBox: false }],
interlaced: true
}))
.pipe(gulp.dest("public/images"))
})
gulp.task("watch", function() {
watch("assets/*.html", ["html"]);
watch("assets/css/*.scss", ["sass"]);
watch("assets/javascript/*.js", ["scripts"]);
watch("assets/images/*.+(jpg|jpeg|png|gif)", ["imgs"]);
});
gulp.task("default", ["html", "sass", "scripts", "imgs", "watch"]);
问题。 为什么gulp watch在调用 gulp watch 或 gulp default 后无法跟踪更改?