Gulp 少吞咽合并几个文件,让其他文件分开

Gulp 少吞咽合并几个文件,让其他文件分开,gulp,less,Gulp,Less,说我有 main1.less main2.less main3.less other1.less other2.less other3.less 我需要输出 main.css other1.css other2.css other3.css 我知道 实际上,它生成的css文件更少。。。是否有一种方法可以将多个文件合并到一个文件中,而将其他文件合并到单独的文件中?您可以通过使用从单独的任务中将所需的样式合并到一个文件中来完成此操作 const gulp=require('gulp4'); co

说我有

main1.less
main2.less
main3.less
other1.less
other2.less
other3.less
我需要输出

main.css
other1.css
other2.css
other3.css
我知道


实际上,它生成的css文件更少。。。是否有一种方法可以将多个文件合并到一个文件中,而将其他文件合并到单独的文件中?

您可以通过使用从单独的任务中将所需的样式合并到一个文件中来完成此操作

const gulp=require('gulp4');
const-less=需要('gulp-less');
const concat=require('gulp-concat');
const path=require('path');
常量配置={
路径:[path.join(_dirname,'less','includes')]
};
gulp.task('less:separate',()=>gulp
.src(path.join(uu dirname,'Content','css','**','other*.less'))
.管道(更少(配置))
.pipe(gulp.dest(path.webroot+'css'));
吞咽任务('less:together',()=>吞咽
.src(path.join(uu dirname,'Content','css','**','main*.less'))
.管道(更少(配置))
.pipe(concat('main.css')//将它们合并到一个文件中
.pipe(gulp.dest(path.webroot+'css'));
吞咽任务('less',吞咽平行('less:separate','less:together');
gulp.task('less', function () {
    return gulp.src(['./Content/css/**/*.less'])
        .pipe(less({
            paths: [path.join(__dirname, 'less', 'includes')]
        }))
        .pipe(gulp.dest(paths.webroot + 'css'));
});