feat: update build script to include post-build processing and add postbuild script for more directory setup
This commit is contained in:
1 parent
4c5352a3e2
commit
1013b51f25
3 files changed
+14
-2
No files matched your search
+1
-1
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"build": "tsc -b && vite build && node scripts/postbuild.mjs",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const indexHtml = readFileSync(resolve(root, "dist", "index.html"), "utf8");
|
||||
|
||||
const moreDir = resolve(root, "dist", "more");
|
||||
mkdirSync(moreDir, { recursive: true });
|
||||
writeFileSync(resolve(moreDir, "index.html"), indexHtml);
|
||||
|
||||
console.log("Copied dist/index.html -> dist/more/index.html");
|
||||
+1
-1
@@ -7,7 +7,7 @@ import MorePage from "./pages/MorePage";
|
||||
export default function App() {
|
||||
const { pathname } = window.location;
|
||||
|
||||
if (pathname === "/more" || pathname === "/more/") {
|
||||
if (/^\/more(\/index\.html)?\/?$/.test(pathname)) {
|
||||
return <MorePage />;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user