Created
June 15, 2016 14:47
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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