Open BrandonSchreck opened 8 years ago
I had this same issue too. Check out: https://www.npmjs.com/package/gulp-useref, specifically the body under 'Migration from v2 API.' Fair warning: that got me past this issue, and I'm currently stuck on serving the build.
EDIT: Fixed my serve-build task issue. It had nothing to do with useref. Best of luck.
Following the examples and earlier posted above, I tried to stay as close as possible to what was being demonstrated in the course. Here is the resulting code for the optimize task that I eventually got working for the course section Minifying and Filtering, also below it are the devDependencies from my package.json to show which versions I was using. Note that farther along in the course you will need to refer to BrandonSchreck's earlier comment.
gulp.task('optimize', ['inject', 'fonts', 'images'], function() {
var templateCache = config.temp + config.templateCache.file;
var cssFilter = $.filter('**/*.css', {restore: true});
var jsFilter = $.filter('**/*.js', {restore: true});
return gulp
.src(config.index)
.pipe($.plumber())
.pipe($.inject(
gulp.src(templateCache, {read: false}), {
starttag: '<!-- inject:templates:js -->'
}))
.pipe($.useref({searchPath: './'}))
.pipe(cssFilter)
.pipe($.csso())
.pipe(cssFilter.restore)
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore)
.pipe(gulp.dest(config.build));
});
from package.json:
"devDependencies": {
"browser-sync": "^2.16.0",
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-angular-templatecache": "^2.0.0",
"gulp-autoprefixer": "^3.1.1",
"gulp-csso": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-if": "^2.0.1",
"gulp-imagemin": "^3.0.3",
"gulp-inject": "^4.1.0",
"gulp-jscs": "^4.0.0",
"gulp-jshint": "^2.0.1",
"gulp-less": "^3.1.0",
"gulp-load-plugins": "^1.3.0",
"gulp-minify-html": "^1.0.6",
"gulp-nodemon": "^2.1.0",
"gulp-plumber": "^1.1.0",
"gulp-print": "^2.0.1",
"gulp-task-listing": "^1.0.1",
"gulp-uglify": "^2.0.0",
"gulp-useref": "^3.1.2",
"gulp-util": "^3.0.7",
"jshint": "^2.9.3",
"jshint-stylish": "^2.2.1",
"wiredep": "^4.0.0",
"yargs": "^5.0.0"
}
While following along your pluralsight video, the following gulp task results in an error 'TypeError: $GLP.useref.assets is not a function'.
As per gulp-useref documentation, v3 no longer uses:
but instead uses the following syntax:
I was able to find a workaround while digging around the inner tubes but it does not append a version to the index.html page itself. Hopefully this will help others.