C
C
Captain_S2015-05-10 10:52:38
PHP
Captain_S, 2015-05-10 10:52:38

Where is the error in gulp task: watch?

I adjusted the template for myself, and since I had not yet mastered the preprocessors, I tried to replace the piece of code responsible for assembling sass files with assembling regular css files. The main build task works correctly and the files are built correctly, and when the watch command is executed in the terminal, the build is reported to start, but nothing actually happens.
Actually code:

'use strict';

var gulp = require('gulp'),
    watch = require('gulp-watch'),
    prefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
   sourcemaps = require('gulp-sourcemaps'),
    rigger = require('gulp-rigger'),
    cssmin = require('gulp-minify-css'),
    imagemin = require('gulp-imagemin'),
    pngquant = require('imagemin-pngquant'),
    rimraf = require('rimraf'),
    browserSync = require("browser-sync"),
    reload = browserSync.reload;

var path = {
    build: {
        html: 'build/',
        js: 'build/js/',
        css: 'build/css/',
        img: 'build/img/',
        fonts: 'build/fonts/'
    },
    src: {
        html: 'src/*.html',
        js: 'src/js/main.js',
        style: 'src/style/main.css',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    watch: {
        html: 'src/**/*.html',
        js: 'src/js/**/*.js',
        style: 'src/style/**/*.css',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    clean: './build'
};

<b>gulp.task('style:build', function () {
    gulp.src(path.src.style)
        .pipe(prefixer())
        .pipe(cssmin())
        .pipe(gulp.dest(path.build.css))
        .pipe(reload({stream: true}));
});</b>

gulp.task('watch', function(){
    watch([path.watch.style], function(event, cb) {
        gulp.start('style:build');
    });
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2018-05-29
@SilenceOfWinter

(?xs)
sprintf_w\(
(
  (?: " (?: [^"\\] | \\. )*+ "
    | ' (?: [^'\\] | \\. )*+ '
    | [^"',()]+
    | \( (?1) \)
  )*+
)

https://regex101.com/r/99EvJP/1
https://ideone.com/GG85ka

Y
Yuri Yarosh, 2015-05-10
@voidnugget

So it has not been working for a very long time ...
It must be so

gulp.task('doStuff', function(done) {done();});
gulp.task('watch', function(){
    gulp.watch(['dist/**'], 'doStuff')
            .on('change', function(file) {
                fileChanged(file.path);
            });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question