From 6316595b7c9ac5d7ea6ac518edab96300140c9f7 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 9 Sep 2023 19:18:39 +0100 Subject: :memo: Idk docs lol. --- docs/vite.config.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'docs/vite.config.js') 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"), + }, + }, + }, })); -- cgit v1.2.3