Skip to content

injecting into different places in the same file seems broken #135

@gruppjo

Description

@gruppjo

I've been injecting different files from different streams into different injection blocks of the same file as described here: https://github.com/klei/gulp-inject#injecting-some-files-into-head-and-some-into-body.

However this doesn't work as expected anymore since I upgraded from 1.5.0 to 2.2.0, neither did I find a way to fix it. It appears that the injections from the first inject are overwritten by the latter.

Here's a simplified example:

gulp.task('inject-all', function () {

  return gulp.src('app/index.html')
    .pipe(
      $.inject( // app/**/*.js files
        gulp.src(paths.jsFiles)))
    .pipe(
      $.inject( // inject compiled css
        gulp.src('.tmp/*/styles/*.css', {read: false})))
    .pipe(gulp.dest('app'));
});

While with version 1.5.0 this produced the following output in the index.html:

<!-- inject:css -->
<link rel="stylesheet" href="blank/styles/blank.css">
<link rel="stylesheet" href="main/styles/main.css">
<link rel="stylesheet" href="side/styles/side.css">
<!-- endinject -->
...

<!-- inject:js -->
<script src="app.js"></script>
<script src="side/side.js"></script>
...
<!-- endinject -->

With version 2.2.0 the output is:

<!-- inject:css -->
<link rel="stylesheet" href="blank/styles/blank.css">
<link rel="stylesheet" href="main/styles/main.css">
<link rel="stylesheet" href="side/styles/side.css">
<!-- endinject -->
...

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

Anyone else experiencing this issue? This keeps me from upgrading to the new version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions