Search code examples
angularjsgulpinjectgulp-inject

Gulp is not injecting js files into index.html


When I run the my task it says files are injected to index.html in the console; but there is no js files injected in the index.html file actually.

my task functions is as follow

gulp.task('testing', function() {
  gulp.src('../dist/app/index.html')
  .pipe(debug())
  .pipe(inject(gulp.src('../dist/app/js/*.js', {read: false}), {relative: true}))
  .pipe(debug())
  .pipe(gulp.dest('../dist/app/js'));
});

I am using gulp3.9.1 and gulp-inject version 3.0.0, any help is advance appreciated.


Solution

  • It seems like the destination path specified points to js directory '../dist/app/js' See if the new file is in js folder. If yes, you probably don't want /js part in the path

    Also you can try to add

    <!-- inject:js -->
    <!-- endinject -->
    

    into you index.html at the place where you want your js scripts to be injected