我的gulp脚本有一天工作正常,现在这个。
gulp.task('minify:dashboard', ['inject:dashboard'], function() {
var assets;
return gulp.src(paths.django.templates.root + '/__dashboard.html')
.pipe($.replace('script src="{{ STATIC_URL }}dashboard', 'script src="compile'))
.pipe($.useref({
searchPath: '.'
}))
// versioning assets
.pipe(indexHtmlFilter)
.pipe($.rev())
.pipe($.debug())
.pipe(indexHtmlFilter.restore)
// processing scripts
.pipe(jsFilter)
// .pipe($.uglify({
// preserveComments: $.uglifySaveLicense,
// compress: uglifyCompressOptions
// }))
.pipe($.size())
.pipe(gulp.dest(paths.django.assets.dashboard + '/builds'))
.pipe(jsFilter.restore)
// updating references
.pipe($.revReplace())
// adding django static url reference
.pipe($.replace('src="scripts', 'src="{{ STATIC_URL }}dashboard/builds/scripts'))
.pipe(gulp.dest('compile/builds'));
});
这项任务可以自行解决,例如
gulp minify:dashboard
然而,当我介绍一项新任务时
gulp.task('minify', ['minify:common', 'minify:dashboard']);
上面的任务gulp minify
给了我这个
events.js:154
throw er; // Unhandled 'error' event
^
Error: write after end
at writeAfterEnd (/magneto/dashboard/node_modules/readable-stream/lib/_stream_writable.js:203:12)
at StreamFilter.Writable.write (/magneto/dashboard/node_modules/readable-stream/lib/_stream_writable.js:239:20)
at write (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:80:13)
at DestroyableTransform.emit (events.js:179:7)
at emitReadable_ (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:444:5)
at readableAddChunk (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:187:9)
奇怪的是,我删除了所有过滤器,即
```的js
gulp.task('minify:dashboard', ['inject:dashboard'], function() {
var assets;
return gulp.src(paths.django.templates.root + '/__dashboard.html')
.pipe($.replace('script src="{{ STATIC_URL }}dashboard', 'script src="compile'))
.pipe($.useref({
searchPath: '.'
}))
// versioning assets
//.pipe(indexHtmlFilter)
.pipe($.rev())
.pipe($.debug())
//.pipe(indexHtmlFilter.restore)
// processing scripts
//.pipe(jsFilter)
// .pipe($.uglify({
// preserveComments: $.uglifySaveLicense,
// compress: uglifyCompressOptions
// }))
//.pipe($.size())
//.pipe(gulp.dest(paths.django.assets.dashboard + '/builds'))
//.pipe(jsFilter.restore)
// updating references
.pipe($.revReplace())
// adding django static url reference
.pipe($.replace('src="scripts', 'src="{{ STATIC_URL }}dashboard/builds/scripts'))
.pipe(gulp.dest('compile/builds'));
});
```
然后任务gulp minify
完全正常。 gulp或gulp-filter包是否有问题,或者我使用它错了吗?
我已经在gulp-filter git repo上发布了同样的问题,因为我认为这是一个gulp过滤器的错误。
应该在这做什么?
答案 0 :(得分:0)
对于任何寻求答案的人,原来我更新到gulp 4,从而打破了依赖关系。希望这有帮助。