GULP and LESS import

0

I'm having problems with GULP and LESS importing files.

Previously I had a project, which had a styles.less file which imports the rest of the less files, such as menus, buttons, etc. And when I made a change in one of these children, the changes were reflected directly in the browser.

Now, in another different project, I'm trying to do the same. A file less father and other children that are imported. What happens is that now, when modifying a child, the attributes are not modified until I restart GULP completely, it no longer helps me save the file only.

GULP file

var gulp = require("gulp"),
    less = require("gulp-less"),
    autoprefixer = require("gulp-autoprefixer"),
    sourcemaps = require("gulp-sourcemaps"),
    browser = require("browser-sync").create();

//Sincronización de pantallas
gulp.task('browser-sync', function() {
    browser.init({
        server: {
            baseDir: './'
        },
        notify: {
            styles: {
                top: 'auto',
                bottom: '0'
            }
        },
        injectChanges: true
    });
});

gulp.task("bs-reload", function() {
  browser.reload();
});

//Actualización de los estilos CSS cuando guardemos
gulp.task('styles', function() {
    gulp.src('css/styles.less')
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(autoprefixer({
        browsers: ['last 2 versions'],
        cascade: false
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('css'))
    .pipe(browser.reload({stream:true}));
});

gulp.task('default', ['styles', 'browser-sync'], function () {
    gulp.watch('css/*.less', ['styles']);
});

File styles.less

@import "menu.less";
//resto de código css aquí

I have read that if styles.less makes an import, and gulp only does the watch to it, it does not take into account the imported files and does not update them. But in a previous project if you do it to me, and this is very strange to me.

I hope you can help me with this.

Update:

I made a change. I updated the json and node_modules from the previous file to the current one, and now yes it works. Is it possible that some update has broken this?

    
asked by Cheshire 16.04.2018 в 13:58
source

0 answers