aboutsummaryrefslogtreecommitdiff
path: root/docs/vite.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'docs/vite.config.js')
-rw-r--r--docs/vite.config.js36
1 files changed, 35 insertions, 1 deletions
diff --git a/docs/vite.config.js b/docs/vite.config.js
index 555777e..bf6cad8 100644
--- a/docs/vite.config.js
+++ b/docs/vite.config.js
@@ -1,14 +1,48 @@
import { defineConfig } from "vite";
import { ghPages } from "vite-plugin-gh-pages";
+import { resolve } from "path";
import gleam from "vite-gleam";
+import { execSync } from "child_process";
+
+const moveForDeployment = {
+ name: "vite-plugin-move-for-deployment",
+ apply: "build",
+ closeBundle() {
+ const temp = resolve(__dirname, ".temp");
+ const dist = resolve(__dirname, "dist");
+
+ execSync(`mkdir ${temp}`);
+ execSync(`mv ${dist}/* ${temp}`);
+ execSync(`rm -rf ${dist}`);
+ execSync(`mkdir ${dist} && mkdir ${dist}/lustre`);
+ execSync(`mv ${temp}/* ${dist}/lustre`);
+ execSync(`rm -rf ${temp}`);
+ execSync(`mv ${dist}/lustre/404.html ${dist}/404.html`);
+ execSync(`mv ${dist}/lustre/CNAME ${dist}/CNAME`);
+ },
+};
export default defineConfig(({ command }) => ({
- base: command === "build" ? "/gleam-lustre/" : "/",
+ base: command === "build" ? "/lustre/" : "/",
+ server: {
+ host: "0.0.0.0",
+ },
plugins: [
gleam(),
+ command === "build" && moveForDeployment,
ghPages({
branch: "docs",
message: "🚀 Deploy to gh-pages.",
}),
],
+ build: {
+ outDir: "dist",
+ emptyOutDir: true,
+ rollupOptions: {
+ input: {
+ main: resolve(__dirname, "index.html"),
+ 404: resolve(__dirname, "404.html"),
+ },
+ },
+ },
}));