34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import tailwindcss from "@tailwindcss/vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { rm } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { defineConfig, type Plugin } from "vite";
|
|
|
|
/**
|
|
* The user's source map art (public/assets/map) is large and only an input to
|
|
* scripts/map-art.mjs; the app loads public/assets/map-gen. Drop the sources
|
|
* from the build output (decision 0.5.37).
|
|
*/
|
|
function omitSourceArt(): Plugin {
|
|
let outDir = "dist";
|
|
return {
|
|
name: "omit-source-art",
|
|
apply: "build",
|
|
configResolved(config) {
|
|
outDir = config.build.outDir;
|
|
},
|
|
async closeBundle() {
|
|
await rm(join(outDir, "assets/map"), { recursive: true, force: true });
|
|
},
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss(), omitSourceArt()],
|
|
server: {
|
|
// Same-domain API in development too (decision 0.5.20). The server listens on
|
|
// IPv4 only, so target 127.0.0.1 rather than localhost.
|
|
proxy: { "/api": "http://127.0.0.1:3000" },
|
|
},
|
|
});
|