How to compile all .less files in a single .css file

1

I'm trying to configure Gulp in my project, but when I compile the .less files it generates a new .css for each .less, I wanted Gulp to compile all the .less and the result was just a "result.css" . follows my current gulpfile.js below:

var gulp = require('gulp');
var less = require('gulp-less');
var plumber = require('gulp-plumber'),
    browserSync = require('browser-sync'),
    reload = browserSync.reload;

// Compiles less on to /css
gulp.task('less', function () {
  gulp.src('src/**/*.less')
    .pipe(plumber())
   .pipe(less())
   .pipe(gulp.dest('src'))
    .pipe(reload({stream:true}));
});

// reload server
gulp.task('browser-sync', function() {
    browserSync({
        server: {
            baseDir: "./"
        }
    });
});

// Reload all Browsers
gulp.task('bs-reload', function () {
    browserSync.reload();
});


// watch for changes on files
gulp.task('watch', function(){ 
  gulp.watch('src/**/*.less', ['less']);
  gulp.watch("*.html", ['bs-reload']);
}); 

// deploys
gulp.task('default',  ['less', 'watch', 'browser-sync']);
    
asked by anonymous 05.11.2015 / 14:49

1 answer

1

I managed to solve my problem, very simple, in the task less I replace the .src with

gulp.src('src/main.less')

And in that main.less I called the other files with @import

@import "home.less";
@import "variables.less";

The result was the two files compiled into a single file, main.css

    
05.11.2015 / 15:12