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

Angular generator for useref.restore() #145

Closed igrek8 closed 8 years ago

igrek8 commented 8 years ago

.pipe($.useref.restore()) raises error and undefined

Generated through yo generator for angular.

gulp.task('client:build', ['html', 'styles'], function () {
  var jsFilter = $.filter('**/*.js', { restore: true });
  var cssFilter = $.filter('**/*.css', { restore: true });

  $.util.log(typeof($.useref.restore) === 'function');

  return gulp.src(paths.views.main)
    .pipe($.useref.assets({searchPath: [yeoman.app, '.tmp']}))
    .pipe(jsFilter)
    .pipe($.ngAnnotate())
    .pipe($.uglify())
    .pipe(jsFilter.restore())
    .pipe(cssFilter)
    .pipe($.minifyCss({cache: true}))
    .pipe(cssFilter.restore())
    .pipe($.rev())
    .pipe($.useref.restore())
    .pipe($.revReplace())
    .pipe($.useref())
    .pipe(gulp.dest(yeoman.dist));
});

What am I doing wrong?

igrek8 commented 8 years ago

Solved

var assets = $.useref.assets({searchPath: [yeoman.app, '.tmp']});

.pipe(assets) .. .pipe(assets.restore())