11var gulp = require ( 'gulp' ) ;
22var $ = require ( 'gulp-load-plugins' ) ( ) ;
3+ var runSequence = require ( 'run-sequence' ) ;
34
45/////////////
56// OPTIONS //
@@ -93,7 +94,7 @@ gulp.task('clean-css', function (cb) {
9394////////////////
9495
9596// Compile Sass
96- gulp . task ( 'sass' , [ 'clean-css' ] , function ( ) {
97+ gulp . task ( 'sass' , function ( ) {
9798 return gulp . src ( __SRC_SASS )
9899 // (optional) sourcemaps
99100 . pipe ( $ . if ( __SOURCEMAPS , $ . sourcemaps . init ( ) ) )
@@ -118,6 +119,11 @@ gulp.task('sass', ['clean-css'], function () {
118119 . pipe ( gulp . dest ( __DIST_CSS ) )
119120} ) ;
120121
122+ // Clean CSS & Compile Sass
123+ gulp . task ( 'sass:build' , function ( callback ) {
124+ runSequence ( 'clean-css' , 'sass' , callback )
125+ } ) ;
126+
121127// Watch Sass
122128gulp . task ( 'sass:watch' , function ( ) {
123129 gulp . watch ( __WATCH_SASS , [ 'sass' ] )
@@ -155,7 +161,7 @@ var bundleLogger = {
155161}
156162
157163// Compile Browserify bundles
158- gulp . task ( 'browserify' , [ 'clean-browserify' ] , function ( callback ) {
164+ gulp . task ( 'browserify' , function ( callback ) {
159165
160166 globby ( __SRC_BROWSERIFY ) . then ( function ( bundles ) {
161167
@@ -238,6 +244,11 @@ gulp.task('browserify', ['clean-browserify'], function (callback) {
238244 } ) ;
239245} ) ;
240246
247+ // Clean & Compile bundles
248+ gulp . task ( 'browserify:build' , function ( callback ) {
249+ runSequence ( 'clean-browserify' , 'browserify' , callback )
250+ } ) ;
251+
241252// Watch Browserify Bundles
242253gulp . task ( 'browserify:watch' , function ( ) {
243254 gulp . watch ( __WATCH_BROWSERIFY , [ 'browserify' ] )
@@ -261,7 +272,7 @@ swigMarked.configure({
261272} ) ;
262273
263274// Compile Swig
264- gulp . task ( 'html' , [ 'html:clean' ] , function ( ) {
275+ gulp . task ( 'html' , function ( ) {
265276 return gulp . src ( __SRC_HTML )
266277 . pipe ( $ . frontMatter ( { property : 'data' } ) )
267278 . pipe ( $ . swig ( {
@@ -275,12 +286,14 @@ gulp.task('html', ['html:clean'], function () {
275286 swigMarked . useTag ( swig , 'markdown' ) ;
276287 }
277288 } ) )
289+ . pipe ( $ . changed ( __DIST , { hasChanged : $ . changed . compareSha1Digest } ) )
278290 . pipe ( gulp . dest ( __DIST ) ) ;
279291} ) ;
280292
281- // Prettify HTML
293+ // Compile Swig & Prettify HTML
282294gulp . task ( 'html:prettify' , [ 'html' ] , function ( ) {
283295 return gulp . src ( __DIST + '/**/*.html' )
296+ . pipe ( $ . changed ( __DIST , { hasChanged : $ . changed . compareSha1Digest } ) )
284297 . pipe ( $ . prettify ( {
285298 indent : 4 ,
286299 indent_inner_html : false ,
@@ -292,6 +305,11 @@ gulp.task('html:prettify', ['html'], function () {
292305 . pipe ( gulp . dest ( __DIST ) ) ;
293306} ) ;
294307
308+ // Clean HTML, Compile Swig & Prettify HTML
309+ gulp . task ( 'html:build' , function ( callback ) {
310+ runSequence ( 'html:clean' , 'html:prettify' , callback )
311+ } ) ;
312+
295313// Watch HTML
296314gulp . task ( 'html:watch' , [ 'watch:set' ] , function ( ) {
297315 gulp . watch ( __WATCH_HTML , [ 'html:prettify' ] )
@@ -326,4 +344,4 @@ gulp.task('watch:set', function (cb) {
326344gulp . task ( 'watch' , [ 'sass:watch' , 'browserify:watch' , 'html:watch' ] ) ;
327345
328346// Default
329- gulp . task ( 'default' , [ 'copy:vendor' , 'sass' , 'browserify' , 'html' , 'html:prettify '] ) ;
347+ gulp . task ( 'default' , [ 'copy:vendor' , 'sass:build ' , 'browserify:build ' , 'html:build ' ] ) ;
0 commit comments