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

泄露秘密 提交于 2019-12-11 08:18:52

问题


I am facing below issue -

I have Yeomen generator and wiredep to inject bower dependencies in index.html file.

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.

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

So how to inject that file in 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.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.


回答1:


It doesn't have to do anything with your gulp task. Wiredep uses bower.json file to inject dependency in your index file.

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

     "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 :)



来源:https://stackoverflow.com/questions/41263475/gulp-and-wire-dep-not-injecting-file-type-js-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!