D
D
Daria Farbak2021-07-16 18:28:16
gulp.js
Daria Farbak, 2021-07-16 18:28:16

Error in Gulp, how to solve?

Hello, the error is :TypeError: watch(...).on is not a function. Please help me fix it.
the code:

const { src, dest, watch, parallel } = require('gulp');

const scss = require('gulp-sass');
const concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const browserSync = require('browser-sync').create();


function browsersync() {
    browserSync.init({
        server: {
            baseDir: 'app/'
        }
    })
}

function styles() {
    return src('app/scss/style.scss')
        .pipe(scss({ outputStyle: 'compressed' }))
        .pipe(concat('style.min.css'))
        .pipe(autoprefixer({
            overrideBrowserslist: ['last 10 versions'],
            grid: true
        }))
        .pipe(dest('app/css'))
        .pipe(browserSync.stream())
}

function scripts() {
    return src([
        'node_modules/jquery/dist/jquery.js',
        'app/js/main.js'
    ])
        .pipe(concat('main.min.js'))
        .pipe(uglify())
        .pipe(dest('app/js'))
        .pipe(browserSync.stream())
}

function watching() {
    watch(['app/scss/**/*.scss'], styles);
    watch(['app/js/**/*.js', '!app/js/main.min.js'], scripts);
    watch(['app/*.html']).оn('chenche', browserSync.reload);
}

exports.styles = styles;
exports.scripts = scripts;
exports.browsersync = browsersync;
exports.watching = watching;
exports.default = parallel(styles, scripts, browsersync, watching);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-07-17
@FDAsha

- watch(['app/*.html']).оn('chenche', browserSync.reload);
+ watch(['app/*.html'], done => {
+     browserSync.reload();
+     done();
+ });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question