![](/img/trans.png)
[英]how to config gulp file with gulp-useref for concatenate html file to js files?
[英]Gulp and wire dep not injecting file type *.*.js files
我面临以下问题-
我有Yeomen生成器和wiredep将Bower依赖项注入index.html文件中。
我已经通过bower安装了角度树视图,然后注意到角度树视图的lib文件和css文件没有注入索引文件中。
经过一段时间的调试后,发现角树视图的lib文件具有一个与css文件相同的附加点(angular.treeview.js)
那么如何将文件注入index.html
我在gulp文件夹中的inject.js文件中有下面的任务要在由yoemen生成的index.html中注入文件
gulp.task('inject', ['scripts'], function () {
var injectStyles = gulp.src([
path.join(conf.paths.src, '/app/**/*.css')
], { read: false });
var injectScripts = gulp.src([
path.join(conf.paths.src, '/app/**/*.module.js'),
path.join(conf.paths.src, '/app/**/*.js'),
path.join('!' + conf.paths.src, '/app/**/*.spec.js'),
path.join('!' + conf.paths.src, '/app/**/*.mock.js')
])
.pipe($.angularFilesort()).on('error',conf.errorHandler('AngularFilesort'));
var injectOptions = {
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};
return gulp.src(path.join(conf.paths.src, '/*.html'))
.pipe($.inject(injectStyles, injectOptions))
.pipe($.inject(injectScripts, injectOptions))
.pipe(wiredep(_.extend({}, conf.wiredep)))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
}
我正在使用也门和大口吃。 任何帮助,将不胜感激。
它与您的gulp任务无关。 Wiredep使用bower.json文件将依赖项注入到索引文件中。
我遇到任何问题,例如在您当前的情况下,您只需要覆盖您的软件包,就像您进行引导一样。 在bower.json中添加以下代码
"overrides": {
"bootstrap": {
"main": [
"dist/css/bootstrap.css",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff",
"dist/fonts/glyphicons-halflings-regular.woff2"
]
},
"angular-treeview":{
"main":[
"angular.treeview.js",
"css/angular.treeview.css"
]
}
}
希望对您有帮助。 快乐的编码:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.