Q
Q
Qairat2017-09-04 09:13:47
gulp.js
Qairat, 2017-09-04 09:13:47

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

Here is my gulpfile.js file
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']);

I think the problem is in specifying the path ./*.html.
In the folder, the files are located like this, all on the same level:
-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

3 answer(s)
O
oh, 2017-09-04
well @AnneSmith

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

E
Egor Zhivagin, 2017-09-04
@Krasnodar_etc

Here in this line you are telling to execute the ./*.html task while watching sassFiles

W
wbrapist, 2017-09-04
@wbrapist

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']);
});

Write
gulp.task('watch',['sass', 'browserSync'], function () {
    gulp.watch(sassFiles, './*.html', ['sass']);
});

(Square brackets removed)
Better yet, rewrite it like this:
gulp.task('watch',['sass', 'browserSync'], function () {
    gulp.watch(sassFiles, ['sass']);
    gulp.watch('./*.html', browserSync.reload);
});

Just think. sassFiles is the same line. She has no sq. brackets, and the second path to html files for some reason is already in square brackets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question