Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialFynn Lehnert
15,244 PointsTypeError: useref.assets is not a function
Attention everyone! useref recently updated to v3.
check github for migrating from v2 to v3.
just sat half an hour searching my script for errors.
https://github.com/jonkemp/gulp-useref
still throws errors like Error in plugin 'gulp-uglify'
anyone have an answer for me?
greets, fynn
3 Answers
Fynn Lehnert
15,244 Pointsmanaged to figure out the answer by myself
this does the job!
gulp.task('html', function() {
return gulp.src(options.src + '/index.html')
.pipe(useref())
.pipe(iff('*.js', uglify()))
.pipe(gulp.dest(options.dist))
});
Viktor Yakov
Front End Web Development Techdegree Graduate 15,770 PointsI also encountered this problem. I was watching the WorkShop "Using Gulp's 'gulp-useref' For a Full Build Pipeline" with the teacher Huston Hedinger. Somewhere in the course I had an error "TypeError: useref.assets is not a function". Took me a while to solve this problem I found solution on "npmjs", "https://www.npmjs.com/package/gulp-useref. The problem is because they changed the versions from v2 to v3. In the video Huston Hedinger apparently works with v2. Here is the solution.
var useref = require('gulp-useref'),
gulpif = require('gulp-if');
gulp.task('html', function() {
return gulp.src(options.src + '/index.html')
.pipe(useref())
.pipe(gulpif('*.js', uglify()))
.pipe(gulp.dest(options.dist));
});'''
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsThanks, I think it works now.