Run gulp task when JS changed


#1

Hi, I added a gulp task to concatenate all js files in order to dynamically load all JS files. It’s defined in “gulpStartupTasks” in ionic.project file. When I ran “ionic serve”, by default it can detect any JS changes and reload the page.

However, it wouldn’t trigger any gulp task like my concatenation task. Does anyone know how to make it trigger gulp task when it detects any JS changes?

Thanks.


#2

Could you show me what the ionic.project file and gulpfile look like?


#3

wouldn’t help much I reckon, you have to update your gulpfile.js and have something like:

var paths = {
  js: ['./www/js/**/*.js']
};

gulp.task('default', ['gulpStartupTasks', ... ]);

gulp.task('gulpStartupTasks', function(done) {
  gulp.doTheThings()
    .on('end', done);
});

gulp.task('watch', function() {
  gulp.watch(paths.js, ['gulpStartupTasks']);
 ....
});