-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiyanbin
committed
Jun 15, 2023
1 parent
993e90d
commit 7ade2b7
Showing
17 changed files
with
3,285 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
VITE_ENTRY=index | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.