I want to use gulp-useref to concatenate all of my JavaScript files into one.
Within my JavaScript files I have a mixture of pre-minified and non-minified files.
I would like to only uglify files which are not already minified (for build performance reasons) and https://github.com/jonkemp/gulp-useref#transform-streams suggests that this is possible (in fact, it looks easy). The following is my Gulp task definition:
gulp.task('compile', function () {
return gulp.src('index.html')
.pipe(useref({}, lazypipe().pipe(function() {
return gulpif(['*.js', '!*.min.js'], uglify());
})))
.pipe(gulp.dest(paths.build));
});
This works, in that I get a concatenated file but the non-minified files remain unminified (pre-minified files are still minified -- as expected).
My code is partially based on this: https://github.com/craigjennings11/gulp-uglifyjs
Any idea why my files are not being minified?
References