-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
46 lines (41 loc) · 1.07 KB
/
vite.config.ts
File metadata and controls
46 lines (41 loc) · 1.07 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
import 'dotenv/config';
import { defineConfig } from "vite";
import { readdirSync } from "fs";
import { resolve } from "path";
import replace from "@rollup/plugin-replace";
const pagesDir = resolve(__dirname, "client/pages");
const pages = readdirSync(pagesDir).map(page => page.replace(".html", ""));
const routes: Record<string, string> = {};
for (const page of pages) {
routes[page] = `client/pages/${page}.html`;
}
export default defineConfig({
root: "client",
build: {
target: "esnext",
outDir: "../dist/client",
assetsDir: "_",
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
input: routes,
plugins: [
]
}
},
server: {
open: true,
proxy: {
'/api': 'http://localhost:3000'
}
},
plugins: [
replace({
preventAssignment: true,
include: ["**/*.html"],
values: {
"CF_ANALYTICS": `{"token": "${process.env.CF_ANALYTICS_ID}"}` || "",
}
}),
]
});