-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
51 lines (44 loc) · 1.3 KB
/
vite.config.ts
File metadata and controls
51 lines (44 loc) · 1.3 KB
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
import { lstat, readdir } from "node:fs/promises";
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
const realpath = (input: string) => fileURLToPath(new URL(input, import.meta.url));
export default defineConfig({
build: {
lib: {
entry: {
"index": realpath("src/index.ts"),
"c3runtime/index": realpath("src/c3runtime/index.ts"),
"c3runtime/domSide": realpath("src/c3runtime/domSide.ts")
},
formats: ["es"]
},
rollupOptions: {
output: {
dir: ".build",
chunkFileNames: "c3runtime/[name].js",
manualChunks: function(id)
{
if (id.includes("node_modules")) { return "vendor"; }
return undefined;
}
}
},
sourcemap: true
},
plugins: [{
name: "watch:public",
buildStart: async function(): Promise<void>
{
const publicDir = realpath("public");
const publicFiles = await readdir(publicDir, { recursive: true });
for (const filePath of publicFiles.map((fileName) => `${publicDir}/${fileName}`))
{
const stats = await lstat(filePath);
if (stats.isDirectory()) { continue; }
this.addWatchFile(filePath);
}
}
}],
resolve: { alias: { "@": realpath("src/") } },
server: { cors: true }
});