B
B
bad_slavik2017-04-07 12:17:42
Node.js
bad_slavik, 2017-04-07 12:17:42

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'

ps Earlier worked correctly, there was a difficulty at reinstallation of the server. Installed as always, there were no innovations. Also note, when saving the style file, there are constant entries in the terminal starting and finished sass, this was not observed before.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Feninets, 2017-04-07
@fnnzzz

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 question

Ask a Question

731 491 924 answers to any question