0
我正在嘗試使用'gulp-inject'插件將js文件添加到我的索引文件(Angular App)中。Gulp注入輸出,但沒有任何選項正在工作
以下是我的gulpfile.js的一部分:
var source = 'src/';
var index = source + 'index.html';
var js = [
source + '**/*.module.js'
// More file paths
];
gulp.task('injectJs', function() {
return gulp
.src(index)
.pipe($.inject(gulp.src(js, {addRootSlash: false, ignorePath: ['src/']})))
.pipe(gulp.dest(source));
});
我運行任務後,這裏是產生index.html文件的問題的一部分:
<!-- inject:js -->
<script src="/src/js/app.module.js"></script>
<!-- endinject -->
根據在任務中設置的附加選項中,輸出src應爲'js/app.module.js'。
事情我都試過了,在結果沒有變化:
- 在從插件的'ignorePath' issue on github (click here)
- 只包括一個選項(即addRootSlash或ignorePath)
- 使用{CWD一些建議:「JS /'}作爲唯一選項
- 將'js'變量更改爲字符串(即var js = source +'**/*。module.js')
- 將ignorePath更改爲字符串(即ignorePath:'src /')
不知道什麼是錯的,或者別的什麼嘗試。任何幫助將不勝感激!
你傳遞的選項'gulp.src()',而不是'注入()'... –
良好的漁獲!請提交您的發現作爲答案,以便我可以接受它。謝謝! – Ali