Skip to content

Commit

Permalink
♻️ Export site with base URL
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 27, 2020
1 parent ef07d8e commit 35ec506
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"post-process": "ts-node post-process.ts",
"dev": "npm run pre-process && sapper dev",
"build": "npm run pre-process && sapper build --legacy",
"export": "npm run pre-process && sapper export --legacy && npm run post-process",
"export": "npm run pre-process && npm run post-process",
"start": "node __sapper__/build",
"cy:run": "cypress run",
"cy:open": "cypress open",
Expand Down
14 changes: 13 additions & 1 deletion post-process.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import { readFile, writeFile, copyFile } from "fs-extra";
import { readFile, writeFile, copyFile, copy, remove } from "fs-extra";
import { safeLoad } from "js-yaml";
import { join } from "path";
import { execSync } from "child_process";

export const preProcess = async () => {
let config: {
"status-website"?: {
cname?: string;
baseUrl?: string;
};
} = safeLoad(await readFile(join(".", ".upptimerc.yml"), "utf8")) as any;
const baseUrl = config["status-website"]?.baseUrl || "/";

execSync(`sapper export --legacy --basepath ${baseUrl}`, {
stdio: "inherit",
});

if (baseUrl !== "/") {
await copy(join(".", "__sapper__", "export", baseUrl), join(".", "__sapper__", "export"));
await remove(join(".", "__sapper__", "export", baseUrl));
}

try {
const file = await readFile(join("..", "..", ".upptimerc.yml"), "utf8");
Expand Down

0 comments on commit 35ec506

Please sign in to comment.