【发布时间】:2014-07-01 19:25:34
【问题描述】:
我有一个简单的 Gulp 构建过程设置用于测试。我已经多次阅读文档,但似乎无法让 Gulp-inject 将我想要的脚本注入 index.html 文件。
我的 Gulp 文件如下所示:
gulp.task('inject1', function() {
return gulp.src('app/index.html')
.pipe(inject(gulp.src('./app/scripts/app.js', {read : false}))) // Not necessary to read the files (will speed up things), we're only after their paths
.pipe(gulp.dest("dist"));
});
gulp.task('inject2', function() {
return gulp.src('app/scripts/**/*.js', {read : false}) // Not necessary to read the files (will speed up things), we're only after their paths
.pipe(inject("./app/index.html"))
.pipe(gulp.dest("./dist"));
});
这是我的 Index.html 的一部分:
<!-- inject:js -->
<!-- endinject-->
这两个都是从 github 上的文档中复制的。
当我运行这些任务中的任何一个时,控制台只会显示“Started 'inject' Finished 'Inject'”
在我的 ./dist 文件夹中,它创建了一个 Index.html 文件,但没有注入任何 js 文件。
我尝试过输入 src 并以许多不同的方式注入属性,但没有运气。知道我做错了什么吗?
【问题讨论】:
-
我也遇到了同样的问题。看起来它正在执行 noop,因为生成的 HTML 文件只保留了 和 cmets。
-
和我一样。我真的希望有某种调试机制存在。
-
我也有同样的错误信息,但原来我的 index.html 文件是空的!
标签: build gulp gulp-inject