2

I'm trying to take my less files and convert them into css files, then take other css files and combine the two sets together to form one css file. I don't get any errors but the css file is never created. Is there a way to combine two different sets of css together to form one css file? Thanks in advance.

var gulp = require("gulp");
var gulpUtil = require("gulp-util");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var less = require("gulp-less");
var minify = require("gulp-minify-css");
var notify = require("gulp-notify");
var addsrc = require("gulp-add-src");

/*CSS Section*/
gulp.task("build-less", function () {

    return gulp.src([
            "Less/common.less",
            "Less/box.less",
            "Less/callout.less",
            "Less/form-controls.less",
            "Less/form.less",
            "Less/scrollbar.less",
            "Less/overflow-table.less",
            "Less/button.less",
            "Less/theme.less",
            "Less/auto-complete.less"
        ]).pipe(less())
        .pipe(addsrc([
            "Css/bootstrap.css",
                "Css/bootstrap-theme.css",
                "Distribution/Styles/theme.css",
                "Css/font-awesome.css",
                "Css/font-awesome-animation.css",
                "Css/animate.css",
                "Css/bootstrap-select.css"
        ]))
        .pipe(concat("dustball.min.css"))
        .pipe(minify())
        .pipe(gulp.dest("Destination/Styles"));
});
4

1 回答 1

2

刚刚遇到一个插件调用 merge2 并且它有效。以下是更新版本。

var gulp = require("gulp");
var gulpUtil = require("gulp-util");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var less = require("gulp-less");
var minify = require("gulp-minify-css");
var notify = require("gulp-notify");
var merge = require("merge2");

/*CSS Section*/
gulp.task("build-less", function () {
    var cssFiles = gulp.src([
            "Css/bootstrap.css",
            "Css/bootstrap-theme.css",
            "Distribution/Styles/theme.css",
            "Css/font-awesome.css",
            "Css/font-awesome-animation.css",
            "Css/animate.css",
            "Css/bootstrap-select.css"
        ])
        .pipe(concat("css-files.css"));

    var lessCssFiles = gulp.src([
            "Less/common.less",
            "Less/box.less",
            "Less/callout.less",
            "Less/form-controls.less",
            "Less/form.less",
            "Less/scrollbar.less",
            "Less/overflow-table.less",
            "Less/button.less",
            "Less/theme.less",
            "Less/auto-complete.less"
        ])
        .pipe(less())
        .pipe(concat("less-files.css"));

    return merge(cssFiles, lessCssFiles)
        .pipe(concat("dustball.min.css"))
        .pipe(minify())
        .pipe(gulp.dest("Distribution/Styles"));
});
于 2015-07-23T17:58:38.893 回答