代码拉取完成,页面将自动刷新
同步操作将从 qinhua/halo-theme-joe2.0 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const { src, dest, task, series, parallel } = require("gulp");
const webpack = require("webpack-stream");
const less = require("gulp-less");
const autoprefix = require("gulp-autoprefixer");
const uglify = require("gulp-uglify");
const minifyCSS = require("gulp-csso");
const gzip = require("gulp-gzip");
const rename = require("gulp-rename");
const clean = require("gulp-clean");
const path = require("path");
const fs = require("fs");
const resolve = (name) => path.resolve(__dirname, name);
const cssPath = "./source/css/min";
const jsPath = "./source/js/min";
task("clean", () => {
return src([cssPath, jsPath], {
read: false,
allowEmpty: true,
}).pipe(
clean({
force: true,
})
);
});
task("css", () => {
const ignoreFiles = ["video"].map((file) => `./source/css/${file}.less`);
return src("./source/css/*.less", {
ignore: ignoreFiles,
})
.pipe(less())
.pipe(
autoprefix({
overrideBrowserslist: ["> 2%", "last 2 versions", "not ie 6-9"],
cascade: false,
})
)
.pipe(minifyCSS())
.pipe(
rename({
suffix: ".min",
})
)
.pipe(dest(cssPath));
});
task("js", () => {
const getEntryData = () => {
const ignoreFiles = ["pjax.js", "census.js"];
try {
let files = fs.readdirSync("./source/js", "utf-8");
files = files.filter((file) => {
return ignoreFiles.length
? /\.js$/.test(file) && !ignoreFiles.includes(file)
: /\.js$/.test(file);
});
const result = {};
files.forEach((file) => {
const fileName = file.replace(/.js$/, "");
result[fileName] = resolve(`./source/js/${file}`);
});
result.utils = resolve("./source/utils/utils.js");
return result;
} catch (error) {
throw new Error(err);
}
};
return webpack({
mode: "production",
entry: getEntryData(),
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
include: resolve("source"),
exclude: resolve("node_modules"),
options: {
presets: ["@babel/preset-env"],
plugins: ["@babel/plugin-transform-runtime"],
},
},
],
},
stats: "errors-only",
output: {
filename: "[name].min.js",
},
})
.pipe(uglify())
.pipe(dest(jsPath))
.pipe(
gzip({
threshold: "10kb",
})
)
.pipe(dest(jsPath));
});
task("default", series("clean", parallel("css", "js")));
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。