From 1013b51f25039afcd38cc807e9ce9d77d83b3711 Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Fri, 7 Aug 2026 14:29:03 +0800 Subject: [PATCH] feat: update build script to include post-build processing and add postbuild script for more directory setup --- package.json | 2 +- scripts/postbuild.mjs | 12 ++++++++++++ src/App.tsx | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 scripts/postbuild.mjs diff --git a/package.json b/package.json index ce14050..edfd821 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/scripts/postbuild.mjs b/scripts/postbuild.mjs new file mode 100644 index 0000000..bba81ba --- /dev/null +++ b/scripts/postbuild.mjs @@ -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"); diff --git a/src/App.tsx b/src/App.tsx index bbcf223..071fa1c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 ; }