Created
August 3, 2017 23:02
-
-
Save clowestab/df78ee6ded2dc90f8ab5e0d03d743761 to your computer and use it in GitHub Desktop.
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
//Watches our .jsx files and our .js. If any change, it calls the build task. | |
const gulp = require('gulp'); | |
const runSequence = require('run-sequence'); | |
const gutil = require('gulp-util'); | |
//Boolean to hold state of watch JSX watch task | |
let taskOngoing = false; | |
//This task simply sets the taskOngoing boolean to false | |
gulp.task('jsxdone', function(callback) { | |
gutil.log('JSX done executed'); | |
taskOngoing = false; | |
callback(); | |
}); | |
//Does the 'watching' | |
gulp.task('watch', function() { | |
//Watches .jsx files | |
gulp.watch('../../public/assets/jsx/**/*.jsx', function(){ | |
//Indicate that we are running the JSX watch | |
taskOngoing = true; | |
gutil.log('Running JSX watch'); | |
//Once the jsx task is executed we will execute jsxdone | |
runSequence('jsx', 'jsxdone', 'browserify'); | |
//THIS line is discussed below | |
gutil.log('Run sequence is NOT finished'); | |
}); | |
//Watches .js files | |
gulp.watch('../../public/assets/js/**/*.js', function(){ | |
if (!taskOngoing) { | |
gutil.log('Running Javascript watch'); | |
runSequence('browserify'); | |
} else { | |
//If our jsx - browserify watch task is executing then we will not allow this watch to execute | |
gutil.log('SKIPPING Javascript watch. JSX task ongoing ' + (taskOngoing ? "true" : "false")); | |
} | |
}); | |
//Watches .css file for changes | |
gulp.watch('../../public/assets/css/simple.css', ['cssconcat']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment