Answer the question
In order to leave comments, you need to log in
Problem in gulpfile.js in index.html, how to fix?
An error comes out:
[12:06:56] Task './*.html' is not in your gulpfile
[12:06:56] Please check the documentation for proper gulpfile formatting
var gulp = require('gulp'),
neat = require('node-neat').includePaths,
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
sassFiles = 'sass/**/*.scss',
cssDest = 'css/';
gulp.task('sass', function () {
return gulp.src(sassFiles)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(cssDest));
});
gulp.task('browserSync', function(){
browserSync.init(["./*.html", "css/*.css", "js/*.js"], {
server: {
baseDir: "./"
}
});
});
gulp.task('watch',['sass', 'browserSync'], function () {
gulp.watch(sassFiles, ['./*.html'], ['sass']);
});
gulp.task('default', ['sass', 'browserSync', 'watch']);
-css -> style.css
-sass -> style.scss
-node_modules
-gulpfile.js
-index.html
-package.json
Answer the question
In order to leave comments, you need to log in
similar to "css/*.css" it looks like the first two characters are extra in "./*.html" if you specify baseDir: "./"
test different variations
these strings can also be placed in variables like sassFiles
Here in this line
you are telling to execute the ./*.html task while watching sassFiles
Hey.
You have already been written, instead of the usual path, you declared the line as a task, which you do not have at all.
Try instead
gulp.task('watch',['sass', 'browserSync'], function () {
gulp.watch(sassFiles, ['./*.html'], ['sass']);
});
gulp.task('watch',['sass', 'browserSync'], function () {
gulp.watch(sassFiles, './*.html', ['sass']);
});
gulp.task('watch',['sass', 'browserSync'], function () {
gulp.watch(sassFiles, ['sass']);
gulp.watch('./*.html', browserSync.reload);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question