Skip to content

Commit c9c855e

Browse files
committed
feat: use command line args instead of env variable
On Windows, the SSG=true environment variable does not work. It needs a different syntax. To make this functionality cross-platform pass a command line argument instead.
1 parent 6b1c8b8 commit c9c855e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dev": "tsx ./src/vite-server.ts",
1616
"build": "npm run build:spa && npm run build:ssr && npm run build:ssg && npm run build:api",
1717
"build:spa": "vite build",
18-
"build:ssg": "SSG=true tsx ./src/vite-server.ts",
18+
"build:ssg": "tsx ./src/vite-server.ts --ssg",
1919
"build:ssr": "vite build -c vite.config.ssr.ts",
2020
"build:api": "rm -rf .stormkit/api && tsx vite.config.api.ts",
2121
"test": "jest"

src/vite-server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ async function generateStaticPages() {
124124
// Fix the path to the static assets.
125125
Object.keys(manifest).forEach((fileName) => {
126126
if (fileName.startsWith("src/assets")) {
127-
content = content.replaceAll(fileName, manifest[fileName].file);
127+
content = content.replace(
128+
new RegExp(fileName, "g"),
129+
manifest[fileName].file
130+
);
128131
console.log("REPLACING", fileName, "with", manifest[fileName].file);
129132
}
130133
});
@@ -139,8 +142,8 @@ async function generateStaticPages() {
139142
}
140143

141144
(async () => {
142-
if (process.env.SSG === "true") {
143-
console.info("Detected SSG=true - generating static routes...");
145+
if (process.argv.includes("--ssg")) {
146+
console.info("Detected --ssg flag - generating static routes...");
144147
await generateStaticPages();
145148
} else {
146149
createServer();

0 commit comments

Comments
 (0)