Answer the question
In order to leave comments, you need to log in
How to connect gulp-watch?
Good afternoon!
Can you tell me how to properly connect and start tracking for css & js files?
tasks:
const watch = require('gulp-watch');
gulp.task('cssc', () => {
return gulp.src('./build/scss/*.css')
.pipe(sourcemaps.init())
.pipe(csscomb())
.pipe(mmq({
log: true
}))
.pipe(cleanCSS())
.pipe(rename({
suffix: ".min"
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css/'))
});
gulp.task('jsc', () => {
return gulp.src(['bodyload.js', 'toggle.js'].map(file => `./build/js/${file}`))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(rename("scripts.min.js"))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./js/'))
});
gulp.task('watch', function() {
gulp.watch('./build/scss/*.css', ['cssc']);
gulp.watch('./build/js/*.js', ['jsc']);
});
Answer the question
In order to leave comments, you need to log in
https://www.youtube.com/watch?v=r2S423N-ETA I didn’t see this lesson better on youtube at all
Make a task
clean - cleaned build, build - collected, watch - put on observation
Hello, most likely you are using the 4th gulp, where the task call is implemented differently.
Instead of an array, a function is passed as the second argument, either gulp.series or gulp.parralel. In arguments, you pass the names of tasks without any arrays (gulp.series("task", "task")).
PS Put semicolons after the last pipes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question