Answer the question
In order to leave comments, you need to log in
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
(?xs)
sprintf_w\(
(
(?: " (?: [^"\\] | \\. )*+ "
| ' (?: [^'\\] | \\. )*+ '
| [^"',()]+
| \( (?1) \)
)*+
)
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 questionAsk a Question
731 491 924 answers to any question