Answer the question
In order to leave comments, you need to log in
Gulp-watch - how to run browser-sync when changing / adding a folder / file?
Greetings.
The task is to launch browserSync if I add or remove the specified folder (/js/) to the project, or add/remove/change js files in it (all this is done manually).
gulpfile.js looks like this:
var gulp = require('gulp'),
browserSync = require('browser-sync').create(),
watch = require('gulp-watch');
gulp.task('default', ['webserver', 'watch']);
var path = {
watch: {
js: '../js/**/*.js',
},
};
gulp.task('webserver', function() {
browserSync.init({
proxy: 'localhost'
});
});
gulp.task('watch', function() {
gulp.watch(path.watch.js).on('change', browserSync.reload);
});
/project/
-- /dev/
---- gulpfile.js
-- /js/
Answer the question
In order to leave comments, you need to log in
Better late than never :) - googled this question too, stumbled upon this thread with no answer.
As a result, I found a solution - a plugin for sublime https://github.com/NicoSantangelo/sublime-gulp
It allows you to run gulp directly in syblime and set hotkeys to start / restart gulp - a.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question