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

multiple blocks, different rules #134

Closed vdclouis closed 8 years ago

vdclouis commented 9 years ago

Hi, is there a way to execute different methods based on a certain identifier? I would like to do something like this:

<!-- build:js build/pdf.js-->
<script src="vendor/pdfjs/pdf.js"></script>
<!-- endbuild -->

<!-- build:js build/app.js -->
<script src="build/app.js"></script>
<!-- endbuild -->
gulp.task('magic', function () {
var assets = useref.assets();

return gulp.src('*.html')
  .pipe(assets)
  .pipe(gulpif('pdf.js', x(), y(), z() )) // <= I need to identify the pdf.js build block somehow
  .pipe(gulpif('app.js', foo())) // <= I need to identify the app.js build block somehow
  .pipe(assets.restore())
  .pipe(useref())
  .pipe(gulp.dest('dist'));
})
jonkemp commented 9 years ago

Need more info please.

vdclouis commented 9 years ago

@jonkemp I need to run different plugins for different build blocks. But I'm not sure how I can target those build blocks. From the readme there's only examples for basic usages like gulpif('*.css', minify()). I wonder if I can do something like gulpif('buildBlockA', minify()) and gulpif('buildBlockB', concat()). I hope this makes sense ^^

jonkemp commented 8 years ago

Yes, you should be able to do exactly what you are asking. Is there a problem?