Gulp watch, wait for the assignment

I would like to see some files when they change, I would like to start MsBuild and start the reboot using BrowserSync when the build is complete. So far I have this "observer":

gulp.watch([config.templatePath+'/**/*','!'+config.templatePath+'/assets/stylesheets/**/*'],['build']).on('change', function(file) {
    browsersync.reload(file);
});

And this build task:

gulp.task('build', function() {
    return gulp
        .src(config.projectFile)
        .pipe(msbuild({
            toolsVersion: 12.0
        }));
});

This works fine, but the browser restarts before the build is complete. At first I thought it was a problem with gulp -msbuild, but I was forgotten return, see https://github.com/hoffi/gulp-msbuild/issues/8 .

The build task starts before rebooting, but without waiting for its completion. Any ideas how to fix this?

Thanks in advance!

+4
source share
1 answer

, build_reload:

gulp.task('build_reload', function() {
    return gulp
        .src(config.projectFile)
        .pipe(msbuild({
            toolsVersion: 12.0
        }))
        .on('end', function() {
            browsersync.reload();
        }));;
});

watch :

gulp.watch([config.templatePath + '/**/*', '!' + config.templatePath + '/assets/stylesheets/**/*'], ['build_reload']);

, .

+3

All Articles