-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
76 lines (72 loc) · 2.02 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { defineConfig } from "vite";
import { visualizer } from "rollup-plugin-visualizer";
import checker from "vite-plugin-checker";
import * as path from "node:path";
import * as url from "node:url";
import { copy } from "@guanghechen/rollup-plugin-copy";
import { forceMinifyEsm } from "./tools/minify.mjs";
import { resolveUrl } from "./tools/foundry-config.mjs";
function resolve(relativePath: string) {
return path.resolve(url.fileURLToPath(new URL(".", import.meta.url)), relativePath);
}
const COPY_FILES = ["README.md", "LICENSE", "CREDITS.md"];
const config = defineConfig(({ mode }) => ({
root: "src/",
base: resolveUrl("modules/quench/"),
publicDir: resolve("public"),
define: {
"process.env.NODE_ENV": JSON.stringify(mode),
},
server: {
port: 30_001,
open: false,
proxy: {
[`^(?!${resolveUrl("modules/quench")})`]: "http://localhost:30000/",
[resolveUrl("socket.io/")]: {
target: "ws://localhost:30000",
ws: true,
},
},
},
css: {
devSourcemap: true,
},
optimizeDeps: {
esbuildOptions: { target: "es2022" },
},
build: {
outDir: resolve("dist"),
emptyOutDir: true,
sourcemap: true,
target: "es2022",
minify: false, // minifying is done via handrolled plugin
rollupOptions: {
output: {
sourcemapPathTransform: (relative) => {
// Relative paths start with a `../`, which moves the path out of the `systems/pf1` directory.
if (relative.startsWith("../")) relative = relative.replace("../", "");
return relative;
},
},
},
reportCompressedSize: true,
lib: {
name: "quench",
entry: resolve("src/module/quench-init.ts"),
formats: ["es"],
fileName: () => "quench.js",
},
},
plugins: [
checker({
typescript: true,
}),
forceMinifyEsm(),
visualizer({
template: "treemap",
sourcemap: true,
}),
copy({ targets: [{ src: COPY_FILES, dest: resolve("dist") }], hook: "writeBundle" }),
],
}));
export default config;