Answer the question
In order to leave comments, you need to log in
Gulp not working correctly?
Hello. The question is. Installed gulp, when compiling files, styles constantly fly off. It is corrected only when you rewrite the style (you remove something or delete something and save it). I have reinstalled npm and nvm several times already. gulpfile.js has already fixed it too:
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var paths = {
scss: './styles/scss/**',
css: './styles/scss/styles.scss'
};
gulp.task('sass', function () {
return gulp.src(paths.css)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe (sourcemaps.write('./maps'))
.pipe(gulp.dest('./styles/css/'));
});
gulp.task('watch', function () {
gulp.watch(paths.scss, ['sass']);
});
gulp.task('default', ['watch', 'sass'
Answer the question
In order to leave comments, you need to log in
if you work with files remotely, then the file may not have time to be overwritten yet, and watch is already triggered.
try to timeout
gulp.watch('./src/js/*.js', function() {
setTimeout(function () {
gulp.start('js');
}, 300);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question