Skip to content

Instantly share code, notes, and snippets.

@wprudencio
Created March 17, 2016 09:54
Show Gist options
  • Save wprudencio/679c2b31b58fd7d6c53a to your computer and use it in GitHub Desktop.
Save wprudencio/679c2b31b58fd7d6c53a to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
replace = require('gulp-replace');
connect = require('gulp-connect');
gulp.task('hashReplace', function() {
gulp.src(['src/index.html'])
.pipe(replace('{{hash}}', guid()))
.pipe(gulp.dest('./'));
});
gulp.task('serveprod', function() {
connect.server({
root: ['/home/weslei/lixo/estudosgulp'],
fallback: 'index.html',
port: process.env.PORT || 5000, // localhost:5000
livereload: false
});
});
gulp.task('watch', function () {
gulp.watch(['*.html'], ['hashReplace']);
});
gulp.task('default', ['hashReplace', 'serveprod','watch']);
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + s4() + s4() +
s4() + s4() + s4() + s4();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment