gpt4 book ai didi

css - gulpjs 合并 css 和更少

转载 作者:行者123 更新时间:2023-11-28 11:33:46 25 4
gpt4 key购买 nike

我正在尝试使用我的 less 文件并将它们转换为 css 文件,然后使用其他 css 文件并将这两组文件组合在一起形成一个 css 文件。我没有收到任何错误,但从未创建 css 文件。有没有办法将两组不同的 css 组合在一起形成一个 css 文件?提前致谢。

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"));
});

最佳答案

刚遇到一个插件调用 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"));
});

关于css - gulpjs 合并 css 和更少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31594539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com