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

does not work with <!-- inject:js --> or <!-- inject:js --> #133

Open eugenekgn opened 8 years ago

eugenekgn commented 8 years ago
<!-- build:js js/app.js -->
<!-- inject:js -->
<script src="/src/app/app.module.js"></script>
<script src="/src/app/home/home.module.js"></script>
<script src="/src/app/products/product.module.js"></script>
<script src="/src/app/home/home.directives.js"></script>
<script src="/src/app/products/product.services.js"></script>
<script src="/src/app/products/productDetail.controller.js"></script>
<script src="/src/app/products/productEdit.controller.js"></script>
<script src="/src/app/products/productList.controller.js"></script>
<script src="/src/app/common/services/common.services.js"></script>
<script src="/src/app/common/services/product.services.mock.js"></script>
<!-- endinject -->

<!-- inject:templates:js -->

It works without inject:xx but not with

here's my code

gulp.task('optimize', ['inject'], function () {

var assets = $.useref.assets({ searchPath: './' });
var templateCache = config.temp + config.templateCache.file;

return gulp
    .src(config.index)
    .pipe($.plumber())
    .pipe($.inject(gulp.src(templateCache, {
        read: false,
        starttag: '<!-- inject:templates:js -->'
    })))
    .pipe(assets)                           // Gathers assets from html comments
    .pipe(assets.restore())                 // Restores the files to the stream. ex: index.html
    .pipe($.useref())                       // $.useref(): concatenates all files
    .pipe(gulp.dest(config.dist));

});

jonkemp commented 8 years ago

This would be an issue for the https://github.com/digisfera/useref repo. However, https://github.com/taptapship/wiredep might be an alternative solution that would work.

jonkemp commented 8 years ago

@eugenekgn my guess is this doesn't work because the comments are stripped out. Can you confirm this?