我有这个gulp文件
const gulp = require('gulp')
const sass = require('gulp-sass')
const cleanCSS = require('gulp-clean-css')
const rimraf = require('rimraf')
const concat = require('gulp-concat')
gulp.task('clean', function(cb) {
rimraf('./dist/*', cb)
})
gulp.task('sass', function(cb) {
gulp.src('./src/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./dist'))
console.log('before')
cb(undefined)
})
gulp.task('minify', function(cb) {
gulp.src('./src/**/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('./dist'))
console.log('before')
cb(undefined)
})
gulp.task('build:css', ['sass', 'minify'], function() {
gulp.src('./dist/**/*.css')
.pipe(concat('style.min.css'))
.pipe(gulp.dest('./dist'))
console.log('after')
})
gulp.task('build', ['clean'], function() {
gulp.start('build:css')
})
gulp.task('build:watch', function () {
gulp.watch('./src/**/*.scss', ['build'])
})
但是当我运行build:watch
[11:26:18] Using gulpfile C:\dev\web\ikea_design\gulpfile.js
[11:26:18] Starting 'build:watch'...
[11:26:18] Finished 'build:watch' after 16 ms
[11:26:24] Starting 'clean'...
[11:26:24] Finished 'clean' after 11 ms
[11:26:24] Starting 'build'...
[11:26:24] Starting 'sass'...
before
[11:26:24] Finished 'sass' after 12 ms
[11:26:24] Starting 'minify'...
before
[11:26:24] Finished 'minify' after 2.27 ms
[11:26:24] Starting 'build:css'...
after
[11:26:24] Finished 'build:css' after 1.16 ms
[11:26:24] Finished 'build' after 25 ms
即使在之后的之前显示之前的两个,也不会创建style.css.min
。这很奇怪,因为在调用dist
时,css文件应该已经保存在concat
文件夹中。
怎么了?
我在build:css
内运行gulp-debug,它在管道中显示0项