Skip to content

Instantly share code, notes, and snippets.

@chodorowicz
Created June 15, 2016 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chodorowicz/24889b28550a33584b42146c24f74dd6 to your computer and use it in GitHub Desktop.
Save chodorowicz/24889b28550a33584b42146c24f74dd6 to your computer and use it in GitHub Desktop.
assets versioning with gulp-rev, gulp-rev-replace, run-sequence (single folder for both dev and prod)
gulp.task('sass', function () {});
gulp.task('browserify', function () {});
// other tasks...
const paths = {
web: './web/',
webAssets: './web/assets/',
webImages: './web/images/',
};
gulp.task('clean', function () {
del.sync(paths.web);
});
gulp.task('rev', function() {
return gulp.src([`${paths.web}**/*.{css,js,jpg,png,svg}`])
.pipe(rev())
.pipe(gulp.dest(paths.web))
.pipe(rev.manifest({}))
.pipe(gulp.dest(paths.webAssets));
});
gulp.task('revreplace', function(){
var manifest = gulp.src(`${paths.webAssets}rev-manifest.json`);
return gulp.src('./web/*.html')
.pipe(revReplace({ manifest: manifest }))
.pipe(gulp.dest('./web/'));
});
gulp.task('revreplacecss', function(){
var manifest = gulp.src(`${paths.webAssets}rev-manifest.json`);
return gulp.src('./web/assets/*.css')
.pipe(revReplace({manifest: manifest}))
.pipe(gulp.dest('./web/assets/'));
});
gulp.task('build-prod', function(callback) {
runSequence(
['clean'],
['templates', 'browserify', 'sass', 'copyStatic'],
['rev'],
['revreplace'],
callback
);
});
gulp.task('build-dev', function(callback) {
runSequence(
['clean'],
['templates', 'browserify', 'sass', 'copyStatic'],
['browser-sync'],
callback
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment