Skip to content

Instantly share code, notes, and snippets.

@jotka
Created February 17, 2016 04:54
Show Gist options
  • Select an option

  • Save jotka/1b60afb72926fd9f80df to your computer and use it in GitHub Desktop.

Select an option

Save jotka/1b60afb72926fd9f80df to your computer and use it in GitHub Desktop.
'use strict';
module.exports = function (gulp) {
var watch = require('gulp-watch'),
livereload = require('gulp-livereload'),
_ = require('lodash'),
defaults = {
livereload: {
port: 35729
}
},
watchOptions = {
usePolling: true,
awaitWriteFinish: {
stabilityThreshold: 2000,
pollInterval: 100
}
};
gulp.task('watch', function () {
var options = _.merge({}, defaults, gulp.config.server);
livereload.listen(options.livereload.port);
watch('*.js', watchOptions, function () {
gulp.start('lint-js', function () {
livereload.reload();
});
});
watch(['app/**/*.js'], watchOptions, function () {
gulp.start(['lint-js', 'test'], function () {
livereload.reload();
});
});
watch(['!app/**/*Test.ts', '!app/**/*.*test.ts', 'app/**/*.ts'], watchOptions, function () {
gulp.start('inject-js', function () {
livereload.reload();
});
});
watch(['app/**/*Test.ts', 'app/**/*.*test.ts'], watchOptions, function () {
gulp.start('test', function () {
livereload.reload();
});
});
watch('app/**/*.scss', watchOptions, function () {
gulp.start('inject-styles', function () {
livereload.reload();
});
});
watch(['!app/index.html', 'app/**/*.html'], watchOptions, function () {
gulp.start('inject-partials', function () {
livereload.reload();
});
});
watch('bower.json', watchOptions, function () {
gulp.start('inject-bower', function () {
livereload.reload();
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment