我以为我在gulpfile中做错了什么,所以我遵循了本教程,但是仍然遇到相同的问题:https://medium.com/swlh/setting-up-gulp-4-0-2-for-bootstrap-sass-and-browsersync-7917f5f5d2c5
这是该教程中的gulpfile:
const sass = require('gulp-sass');
const browserSync = require('browser-sync').create();
//compile scss into css
function style() {
return gulp.src('src/scss/**/*.scss')
.pipe(sass().on('error',sass.logError))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.stream());
}
function watch() {
browserSync.init({
server: {
baseDir: "./src",
index: "/index.html"
}
});
gulp.watch('src/scss/**/*.scss', style)
gulp.watch('./*.html').on('change',browserSync.reload);
gulp.watch('./js/**/*.js').on('change', browserSync.reload);
}
exports.style = style;
exports.watch = watch; ```