Answer the question
In order to leave comments, you need to log in
What am I doing wrong when setting up gulp browser-sync?
This is my first experience with gulp.
I managed to set up all the necessary plugins except for "browser-sync".
When I start it, the contents of the directory appear on port 3000, and 3001 as the settings should. But the site itself does not appear. and even if you go through the directory to index.html, it gives the error "Cannot GET /app/index.html"
Also in the path I specify the "app" folder as the root, but it still starts from the project folder. (The "app" folder lies inside the project) I read a lot of articles and watched a lot of videos on how to start it, but when I repeat it, two variants of problems appear about the first one already described, and the second is that if I add for example
"gulp.watch('./app/*.html').on('change', browserSync.reload);"
// Лишнее я убрал, но пробовал разные варианты. Я так понял что этот код должен работать при любых обстоятельствах.
const brSync = require('browser-sync').create();
function watchB(){
brSync.init({
sever: "./app"
});
//gulp.watch('./app/*.html').on('change', browserSync.reload);
//watch('app/css/*.css').on('change', browserSync.reload);
//watch('app/js/*.js').on('change', browserSync.reload);
}
exports.w = series(watchB);
gulp.task('s', function () {
brSync.init({
sever: {
baseDir: "./app"
},
notify: false
});
//gulp.watch('./app/**/*.html').on('change', browserSync.reload);
//gulp.watch('app/css/*.css').on('change', browserSync.reload);
//gulp.watch('app/js/*.js').on('change', browserSync.reload);
});
gulp.task('s', function () {
browserSync.init({
server: "./app"
});
//gulp.watch('./app/**/*.html').on('change', browserSync.reload);
//gulp.watch('app/css/*.css').on('change', browserSync.reload);
//gulp.watch('app/js/*.js').on('change', browserSync.reload);
});
Answer the question
In order to leave comments, you need to log in
const brSync = ...
I think, without further ado, it is obvious
and more:
brSync.init({
sever: { // sever?
baseDir: "./app"
},
notify: false
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question