Hi,
I am trying to write a gulp build process but i am stuck in race condition due to watch. I don't know how to overcome this problem.
I am trying to watch html/js/ts changes, and using linker to insert script tags after compiling my code. When linker modifies html file, watch re-runs the whole build process. Don't know how to solve this.
gulp.task('link',function(){
gulp.src('./app/index.html')
.pipe(linker({
scripts: [ "./app/js/*/**.js ",'!./app/js/browserify/*.js'],
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: './app'
}))
.pipe(gulp.dest('./app')).pipe(livereload());
})
gulp.task('watch', function() {
// watch many files
livereload.listen();
gulp.watch(['./app/**/*.html','./app/**/*.ts','./app/js/browserify/*.js']).on('change',function () {
return runSequence(['clean'],
['cleanbundle'],
['compile'],
['lint'],
['browserify'],
['link']);
});
});