GulpタスクでWiredepを使用して、index.htmlファイルにBower依存関係を挿入しようとしています。次のタスク(Wiredepなし)はうまく動作します。なぜ私のgulpタスクで "dest.onは関数ではありません"でWiredepがエラーになっていますか?
は今、私はそれにWiredepを追加しようとしました:
になりvar wiredep = require('wiredep');
gulp.task('build', ['copy', 'assets'], function(){
return gulp.src('app/index.html')
.pipe(wiredep())
.pipe(inject(gulp.src(['dist/assets/js/*.js', 'dist/assets/css/*.css'], {read: false}), {relative: true}))
.pipe(gulp.dest('dist'));
});
:
[09:45:11] TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (C:\GIT\myApp\myApp-front\node_module
s\gulp-debug\node_modules\through2\node_modules\readable-stream\lib\_stream_read
able.js:533:8)
at Gulp.<anonymous> (C:\GIT\myApp\myApp-front\gulpfile.js:38:6)
at module.exports (C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\
orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\GIT\myApp\myApp-front\node_modules\gulp\n
ode_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\GIT\myApp\myApp-front\node_modules\gulp\n
ode_modules\orchestrator\index.js:214:10)
at C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestrator\ind
ex.js:279:18
at finish (C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestr
ator\lib\runTask.js:21:8)
at C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestrator\lib
\runTask.js:52:4
at f (C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestrator\
node_modules\end-of-stream\node_modules\once\once.js:17:25)
at DestroyableTransform.onend (C:\GIT\myApp\myApp-front\node_modules\gulp\n
ode_modules\orchestrator\node_modules\end-of-stream\index.js:31:18)
私が直接using Wiredep from the command lineを試してみましたが、それがうまく実行します。 私はWindowsで、ノードv4.2.2を使用しています。
EDIT 誰もが同じ問題に遭遇した場合は、この問題を回避するには、にタスクを変更することです:
gulp.task('build', ['copy', 'assets'], function(){
wiredep({src:'dist/index.html'});
return gulp.src('dist/index.html')
.pipe(inject(gulp.src(['dist/assets/js/*.js', 'dist/assets/css/*.css'], {read: false}), {relative: true}))
.pipe(gulp.dest('dist'));
});
のindex.htmlを前に注入beeingてのdistディレクトリにコピーされることに注意してください。
私は依然としてストリームを使用して依存関係を配線できないのだろうかと疑問に思っています。