jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

additonalStreams not merging streams #139

Closed Kikketer closed 8 years ago

Kikketer commented 8 years ago

I may just be missing something but I have my setup attempting to merge the output of the angular-templateCache stream with the assets stream. If I make the templateStream spit out to a destination, it produces a single JS file. I assume I can take the output of that stream and add it into the assets to be included into the assets stream.

gulp.task('usemin:dist', ['clean:dist'], function() {
  var templatesStream = gulp.src([
    './app/**/*.html',
    '!./app/index.html',
    '!./app/404.html'
  ]).pipe(templateCache({
    module: 'myCoolApp'
  }));

  var assets = $useref.assets({
    additionalStreams: [templatesStream]
  });

  return gulp.src('./app/index.html')
    .pipe(assets)
    .pipe(assets.restore())
    .pipe($useref())
    .pipe(gulp.dest('./dist/'));
});

After this runs, the resulting JS file does not have the templates contents (only the contents of the JS files that are in my html file).

Kikketer commented 8 years ago

I was able to figure out the issue by adding the templates.js file to my index page. This file 404s while in development, but is created and added during deployments. http://stackoverflow.com/questions/33216528/gulp-useref-additionalstreams-not-merging/33220417#33220417

Thanks for creating test cases, it's what helped me figure out the issue.

jonkemp commented 8 years ago

:+1:

urrri commented 8 years ago

I tried the same with the new version of useref 3.0.8 and it doesn't work. When I add additionalStreams it immediately stops concatenate files, just copy them. But it replaces entries in index.html to target. In addition it tries to add templates.js (I see it via debug and comments in the file)at the beginning of the each section (I have 4) , never mind I add entry to the html or not.

yuricamara commented 8 years ago

"When I add additionalStreams it immediately stops concatenate files, just copy them" Same problem here.

"version": "3.0.8"

jonkemp commented 8 years ago

Since this is a closed issue, can we use #200 which is open for tracking the issues with additionalStreams?

yuricamara commented 8 years ago

Sure!