K
K
Kizzeon2020-02-01 18:06:47
gulp.js
Kizzeon, 2020-02-01 18:06:47

Gulp - BrowserSync says "cant get /", how to solve the problem?

I have a gulpfile that handles css and livereload:

const gulp         = require('gulp'),
    browserSync  = require('browser-sync'),
    concat       = require('gulp-concat'),
    cleanCSS     = require('gulp-clean-css'),
    del          = require('del'),
    autoprefixer = require('gulp-autoprefixer');

gulp.task('styles', function() {
  return gulp.src('./css/*.css')
    .pipe(concat('style.css'))
    .pipe(autoprefixer())
    .pipe(cleanCss({
      level: 2
    }))
    .pipe(gulp.dest('./dist/css'))
});

gulp.task('clean', async function() {
  return del.sync('./dist/css/*');
});

gulp.task('browser-sync', function() {
    browserSync({
        server: { 
            baseDir: './'
        },
        notify: false
    });
});

gulp.task('watch', gulp.series('browser-sync'), function() {
    gulp.watch("./css/*.css", browserSync.reload);
    gulp.watch("./html/*.html", browserSync.reload);
});

gulp.task('default', gulp.series('watch'));
gulp.task('build', gulp.parallel('clean', 'styles'));


The build works well, but the live reload stubbornly refuses to work: If you enter the project folder, then "CANT GET /" is displayed on the page, and if you enter a folder with html files, it updates only html and does not include styles

at all. What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question