简体   繁体   English

Gulp和Wire Dep不注入文件类型*。*。js文件

[英]Gulp and wire dep not injecting file type *.*.js files

I am facing below issue - 我面临以下问题-

I have Yeomen generator and wiredep to inject bower dependencies in index.html file. 我有Yeomen生成器和wiredep将Bower依赖项注入index.html文件中。

I have installed angular tree view by bower then noticed that lib files and css file of angular tree view are not getting injected in index file. 我已经通过bower安装了角度树视图,然后注意到角度树视图的lib文件和css文件没有注入索引文件中。

After debugging for while found that the lib file of angular tree view has one extras dot (angular.treeview.js) same with the css file as well 经过一段时间的调试后,发现角树视图的lib文件具有一个与css文件相同的附加点(angular.treeview.js)

So how to inject that file in index.html 那么如何将文件注入index.html

i have below task in inject.js file in gulp folder to inject file in index.html which is generated by yoemen 我在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')));
}

I am using Yeomen and gulp. 我正在使用也门和大口吃。 Any help would be appreciated. 任何帮助,将不胜感激。

It doesn't have to do anything with your gulp task. 它与您的gulp任务无关。 Wiredep uses bower.json file to inject dependency in your index file. Wiredep使用bower.json文件将依赖项注入到索引文件中。

I case of any issue, like in your current scenario you just need to override your package, like you do for bootstrap. 我遇到任何问题,例如在您当前的情况下,您只需要覆盖您的软件包,就像您进行引导一样。 add below code in 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"
     ]
     }
      }

I hope it will help you. 希望对您有帮助。 Happy coding :) 快乐的编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM