Answer the question
In order to leave comments, you need to log in
Why did browsersync stop running after adding gulp-less?
Hello. I did the project first without less, just on css, everything worked. Thus:
var gulp = require('gulp'),
concatCSS = require('gulp-concat-css'),
bs = require('browser-sync').create(),
gulp.task('default', function(){
return gulp.src('src/*.html')
.pipe(gulp.dest('dist/html'));
});
gulp.task('server', function(){
bs.init({
server: {
baseDir: "src/"
}
});
gulp.watch("src/*.html").on('change', bs.reload);
});
gulp.task('less', function() {
return gulp.src("src/less/*.less")
.pipe(less())
.pipe(gulp.dest("srs/css"))
.pipe(bs.stream());
});
gulp.task('server', 'less', function(){
bs.init({
server: {
baseDir: "src/"
}
});
gulp.watch("src/less/*.less", ['less']);
gulp.watch("src/*.html").on('change', bs.reload);
});
Answer the question
In order to leave comments, you need to log in
You can server
put the task, on the contrary, in watcher
:
For simplicity, create a variable with server settings:
var config = {
server: {
baseDir: "src/"
}
}
Watcher
will look like this:gulp.task('watch', function(){
browserSync.init(config);
gulp.watch("src/less/*.less", gulp.series("less"));
--> x
})
gulp.series
or gulp.parallel
. Their difference is in the order in which tasks are performed. I recommend using gulp.series
for such tasks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question