2017-05-25 4 views
0

私のアプリケーションではgulp-injectを使用していますが、私はの修正方法を実行中にエラーになりますか?`gulp-inject`が` gulp.src`のために用意されているのでしょうか? '

console

PS F:\Nissan-Gulp> gulp 
[14:38:38] Using gulpfile F:\Nissan-Gulp\gulpfile.js 
[14:38:38] Starting 'server'... 
[14:38:38] Finished 'server' after 22 ms 
[14:38:38] Starting 'inject'... 
[14:38:38] 'inject' errored after 19 ms 
[14:38:38] Error in plugin 'gulp-inject' 
Message: 
    There is no `read` option. Did you mean to provide it for `gulp.src` perhaps? 
[14:38:38] Server started http://localhost:9000 
[14:38:38] LiveReload started on port 35729 

私のコード:

gulp.task("inject", function() { 
    var sources = gulp.src(['./app/scripts/**/*.js', './app/stylesheets/**/*.css' ], {read: false}, {relative: true}); 
    return gulp.src('./app/index.html') 
    .pipe(inject(sources, { 
     read: false, 
     ignorePath: '/app' 
    })) 
    .pipe(gulp.dest('./app')); 
}); 

私のhtmlコード:

<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title></title> 
    <meta name="description" content=""> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="/stylesheets/main.css"> 
    <!-- bower:css --> 
    <!-- endbower --> 
    <!-- inject:css --> 
    <!-- endinject --> 
</head> 
<body> 
    <!-- bower:js --> 
    <!-- endbower --> 
    <!-- inject:js --> 
    <!-- endinject --> 
</body> 

答えて

3

変更この:

.pipe(inject(sources, { 
    read: false, 
    ignorePath: '/app' 
})) 

.pipe(inject(sources, { ignorePath: '/app' })) 

へのあなたのソース変数がすでに読み取りオプションが設定されている - 飲み込む-注入しないgulp.srcするオプションです。あなたは正しくVAR源のためにそれを持っているとして、それはgulp.srcの引数リスト内でなければならない理由です:

var sources = gulp.src['./app/scripts/**/*.js', './app/stylesheets/**/*.css' ], {read: false}, {relative: true}); 

ignorePathは、注入のオプションです。読んでそこにリストされていません。 gulp-inject description

関連する問題