Using filewatcher plugin on existing gulp configuration

Hello, 

In my project I'm using gulp for minification of js, compiling scss and making sprites from images.

I have existing gulpfile with commands like this 

gulp.task('watch:scss', function () {
gulp.watch([build.config.path.src + '/sass/**/*.scss', !build.config.path.src + '/sass/oxy/**/*.scss'], gulp.series('build-bundle'));
gulp.watch(build.config.path.src + '/sass/oxy/**/*.scss', gulp.series('sass'));
});

gulp.task('watch:js', function () {
gulp.watch([build.config.path.src + '/js/**/*.js', !build.config.path.src + '/js/oxy/**/*.js'], gulp.series('build-bundle'));
gulp.watch(build.config.path.src + '/js/oxy/**/*.js', gulp.series('scripts'));
});

 

Is there any chance to connect filewatcher on scss/js file changes to do proper gulp action? The gulp is running from console in \os\src\main\webapp\src\tools\gulp like gulp sass for sass compiling. 

How Do I need to set up 2 file watchers? Can anyone help me with this please?

 

For questions about why should filewatcher trigger another file watch: Main reason to do this is that watch program is too slow and better approach is to change the file and run gulp sass (for example). This watcher would do the same.

1
3 comments

Not sure I follow you... Would you like to know how to run certain Gulp task via file watcher? It's esy- you need passing task name as argument. For example, the file watcher below runs `precompile` task that looks as follows:

gulp.task('precompile', function () {
return gulp.src('./src/less/*.less')
.pipe(less({
compress: true
}))
.pipe(gulp.dest('./build/client/css'))
})

2
Avatar
Permanently deleted user

It's working. Thank you very much.

0

I have that same problem.
There is no slowness in VS code but in webstorm it works very late watcher.

-2

Please sign in to leave a comment.