Skip to content

Instantly share code, notes, and snippets.

@Anenth
Created Oct 3, 2014
Embed
What would you like to do?
Gulp build
gulp.task("build:html", function() {
var cssFilter = $.filter(path.styles.css);
var jsFilter = $.filter(path.scripts.distjs);
var gutil = require('gulp-load-utils')(['log']);
return gulp.src(path.html.rawBase)
.pipe($.useref.assets().on("error", gutil.log))
.pipe(jsFilter)
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.csso())
.pipe(cssFilter.restore())
.pipe($.rev())
.pipe($.useref.restore())
.pipe($.useref())
.pipe($.revReplace())
.pipe($.rename('base.html'))
.pipe(gulp.dest(path.html.base))
.pipe($.size({title: 'html'}));
});
gulp.task('build:css', function() {
return gulp.src(path.styles.css)
.pipe($.csso())
.pipe($.rename({
suffix: ".min",
}))
.pipe(gulp.dest(path.dist));
});
gulp.task('build:rev', function () {
return gulp.src([path.styles.css, path.scripts.distjs])
.pipe($.rev())
.pipe(gulp.dest(path.dist)) // write rev'd assets to build dir
.pipe($.rev.manifest())
.pipe(gulp.dest(path.dist)); // write manifest to build dir
});
gulp.task('build', function (cb) {
runSequence('build:css', 'build:rev', ['build:html'], cb);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment