klei/gulp-inject

New inject is overwriting the previous

verdeandrea opened this issue · 3 comments

If i apply a two task with inject on the same file, the last one overwrites the previous.

Here are my two tasks:

gulp.task('html_app', () => {
  gulp.src(srcs.html.srcs+'/**/*.html')
    .pipe(inject(gulp.src('web/static/web/dev/scripts/app.js', {read: false}), {name: 'app'}))
    .pipe(gulp.dest('./dest'))
})

gulp.task('html_libs', () => {
  gulp.src(srcs.html.srcs+'/**/*.html')
    .pipe(inject(gulp.src('web/static/web/dev/scripts/libs.js', {read: false}), {name: 'libs'}))
    .pipe(gulp.dest('./dest'))
})

and this is what i write on my html

<!-- libs:js -->
<!-- endinject -->

<!-- app:js -->
<!-- endinject -->

As you can see I'm using name option but is not working.

@verdeandrea My current workaround is to have all (app and libs) in one injection:

  <!-- Libraries and Application -->
  <!-- inject:js -->
  <script src="node_modules/jquery/dist/jquery.min.js"></script>
  <script src="node_modules/jquery-ui-dist/jquery-ui.min.js"></script>
  <script src="node_modules/tether/dist/js/tether.min.js"></script>
  <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
  <script src="node_modules/handlebars/dist/handlebars.min.js"></script>
  <script src="src/js/app.js"></script>
  <script src="src/js/routing.js"></script>
  <script src="src/js/view.js"></script>
  <script src="src/js/controllers/abstract.js"></script>
  <script src="src/js/controllers/details.js"></script>
  <script src="src/js/controllers/navigation.js"></script>
  <script src="src/js/controllers/orderBy.js"></script>
  <script src="src/js/controllers/properties.js"></script>
  <script src="src/js/controllers/select.js"></script>
  <script src="src/js/controllers/where.js"></script>
  <script src="src/js/ext/smarti.data.js"></script>
  <script src="src/js/storage/local.js"></script>
  <script src="src/js/storage/remote.js"></script>
  <script src="src/js/utils/stringFormat.js"></script>
  <!-- endinject -->

https://github.com/rognoni/adaptable/blob/master/Front-end/HTML5-Bootstrap4/src/html/index.html

thanks @rognoni . So this is actually a bug that has no fix, right?

Ok, sorry guys, that was obviously my mistake. Using a dest that is different from src, it writes the html file starting from the clean source, and clearly owerwrites the previous injection. Using the same folder as src and dest everything is working fine.