While following along your pluralsight video, the following gulp task results in an error 'TypeError: $GLP.useref.assets is not a function'.
gulp.task('optimize', ['inject', 'fonts', 'images'], function () {
log('Optimizing the javascript, css, and html');
var assets = $GLP.useref.assets({searchPath: './'}),
templateCache = config.temp + config.templateCache.file,
cssFilter = $GLP.filter('**/*.css'),
jsLibFilter = $GLP.filter('**/' + config.optimized.lib),
jsAppFilter = $GLP.filter('**/' + config.optimized.app);
return gulp
.src(config.index)
.pipe($GLP.plumber())
.pipe($GLP.inject(gulp.src(templateCache, { read: false }), {
starttag: '<!-- inject:templates:js -->'
}))
.pipe(assets)
.pipe(cssFilter)
.pipe($GLP.csso())
.pipe(cssFilter.restore())
.pipe(jsLibFilter)
.pipe($GLP.uglify())
.pipe(jsLibFilter.restore())
.pipe(jsAppFilter)
.pipe($GLP.ngAnnotate())
.pipe($GLP.uglify())
.pipe(jsAppFilter.restore())
.pipe($GLP.rev())
.pipe(assets.restore)
.pipe($GLP.useref())
.pipe($GLP.revReplace())
.pipe(gulp.dest(config.build))
.pipe($GLP.rev.manifest())
.pipe(gulp.dest(config.build));
});
var gulp = require('gulp'),
useref = require('gulp-useref');
gulp.task('default', function () {
var assets = useref.assets();
return gulp.src('app/*.html')
.pipe(assets)
.pipe(assets.restore())
.pipe(useref())
.pipe(gulp.dest('dist'));
});
var gulp = require('gulp'),
useref = require('gulp-useref');
gulp.task('default', function () {
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulp.dest('dist'));
});
gulp.task('optimize', ['inject', 'fonts', 'images'], function () {
log('Optimizing the javascript, css, and html');
var lazypipe = require('lazypipe'),
templateCache = config.temp + config.templateCache.file,
cssFilter = $GLP.filter('**/*.css', {restore: true}),
jsLibFilter = $GLP.filter('**/' + config.optimized.lib, {restore: true}),
jsAppFilter = $GLP.filter('**/' + config.optimized.app, {restore: true}),
notIndexFilter = $GLP.filter(['**/*', '!**/index.html'], {restore: true});
return gulp
.src(config.index)
.pipe($GLP.plumber())
.pipe($GLP.inject(
gulp.src(templateCache, { read: false }),
{ starttag: '<!-- inject:templates:js -->' }
))
// Apply the concat and file replacement with useref
.pipe($GLP.useref({searchPath: './'}, lazypipe().pipe($GLP.sourcemaps.init,{loadMaps: true})))
// Get the css
.pipe(cssFilter)
.pipe($GLP.csso())
.pipe(cssFilter.restore)
// Get the custom javascript
.pipe(jsAppFilter)
.pipe($GLP.ngAnnotate())
.pipe($GLP.uglify())
.pipe(jsAppFilter.restore)
// Get the vendor javascript
.pipe(jsLibFilter)
.pipe($GLP.uglify())
.pipe(jsLibFilter.restore)
// Take inventory of the file names for future rev numbers
.pipe(notIndexFilter)
.pipe($GLP.rev())
.pipe(notIndexFilter.restore)
// Replace the file names in the html with rev numbers
.pipe($GLP.revReplace())
.pipe($GLP.sourcemaps.write('.'))
.pipe(gulp.dest(config.build))
.pipe($GLP.rev.manifest())
.pipe(gulp.dest(config.build));
});