有一天我的 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 过滤器的错误。
这里应该做什么?