From 4572900a59407d12c9f81f0570841b903518ceb5 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Thu, 5 Feb 2015 13:34:14 -0600 Subject: [PATCH] Wrote first version of hashing task --- gulpfile.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 89910373a7..3755819ec9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,6 +11,7 @@ var gulp = require('gulp'), stylus = require('gulp-stylus'), nib = require('nib'), minifycss = require('gulp-minify-css'), + hash = require('gulp-hash'), rename = require('gulp-rename'), uglify = require('gulp-uglify'), concat = require('gulp-concat'), @@ -54,8 +55,12 @@ var paths = { './bower_components/bootstrap/dist/fonts/*'], dest: './build/' }, - hashres: { - fileNameFormat: '${name}-${hash}.${ext}', + hash: { + options : { + algorithm: 'md5', + hashLength: 8, + template: '<%= name %>-<%= hash %><%= ext %>' + }, src: [ 'website/build/*.js', 'website/build/*.css', 'website/build/favicon.ico', 'common/dist/sprites/*.png', @@ -98,10 +103,6 @@ gulp.task('copy', function() { .pipe(gulp.dest(paths.copy.dest)); }); -gulp.task('hashres', function() { - // @TODO: Finish this -}); - gulp.task('sprite', function(cb) { console.log('Cleaning sprites directory...'); rimraf.sync('./common/dist/sprites'); @@ -239,8 +240,16 @@ gulp.task('build:js', function() { }); }); -gulp.task('build', ['loadManifest', 'clean', 'stylus', 'browserify', 'build:css', 'build:js'], function() { - +gulp.task('build', ['loadManifest', 'clean', 'stylus', 'browserify', 'build:css', 'build:js'], function(cb) { + + gulp.src(paths.hash.src) + .pipe(hash(paths.hash.options)) // Add hashes to the files' names + .pipe(gulp.dest('./website/build')) // Write the now-renamed files + //.pipe(hash.manifest('asset-hashes.json')) // Change the stream to the manifest file + //.pipe(gulp.dest('public')); // Write the manifest file + .on('end', function(){ + cb(); + }); }); gulp.task('watch', ['stylus', 'browserify'], function() {