Skip to content

Commit

Permalink
工具
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyanbin committed Jun 15, 2023
1 parent 993e90d commit 7ade2b7
Show file tree
Hide file tree
Showing 17 changed files with 3,285 additions and 17 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
VITE_ENTRY=index
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
// 'vue/no-unused-vars': 'error'
"vue/no-v-html": "off",
"@typescript-eslint/ban-ts-comment": "off",
"vue/multi-word-component-names": "off",
},
};
40 changes: 40 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { execSync } = require("child_process");
let entry = process.env.VITE_ENTRY || "";
let pages;
if (entry) {
pages = entry.split(",");
} else {
pages = getChangePageName();
if (pages.length == 0) {
console.log("本次提交没有修改页面相关代码");
return;
}
}
function getChangePageName() {
let raw = execSync("git diff --name-only HEAD~1").toString();
let pages = [];
raw = raw.replace(/\n/g, "");
let reg = /src\/pages\/(.+?)\//g;
var page;
while ((page = reg.exec(raw))) {
pages.push(page[1]);
}

return [...new Set(pages)];
}
console.log("本次要打包页面:", pages);
pages.forEach((page) => {
console.log("开始打包:" + page);
try {
execSync(
"npx cross-env VITE_ENTRY=" +
page +
" vite build" +
(process.argv[2] ? " --mode " + process.argv[2] : "")
);
console.log("打包完成:" + page);
} catch (error) {
console.log(error.message);
console.log("打包失败:" + page);
}
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"axios": "^0.26.1",
"dayjs": "^1.11.0",
"jszip": "^3.10.1",
"pinia": "^2.0.11",
"swiper": "^5.4.5",
"vconsole": "^3.14.3",
Expand Down
Loading

0 comments on commit 7ade2b7

Please sign in to comment.