-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
81 lines (73 loc) · 1.83 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
77
78
79
80
81
import * as path from "node:path"
import process from "node:process"
import akte from "akte/vite"
import { listenAndWatch } from "listhen"
import { defineConfig } from "vite"
import { app } from "./src/akte.app"
if (process.env.NODE_ENV === "development") {
listenAndWatch("./src/functions.server.ts", { port: 5174 })
}
export default defineConfig({
root: path.resolve(__dirname, "src"),
server: {
proxy: {
"^/admin.*": "http://localhost:5174",
"^/api.*": "http://localhost:5174",
"^/preview.*": "http://localhost:5174",
},
},
build: {
cssCodeSplit: false,
emptyOutDir: true,
outDir: path.resolve(__dirname, "dist"),
rollupOptions: {
output: {
entryFileNames(chunkInfo) {
// Files being the unique user of a script requires special handling
// of their chunk name for Akte and Vite build to match
if (chunkInfo.moduleIds.some((id) => id.endsWith(".ts"))) {
return `assets/js/${chunkInfo.name.replace(".html", "")}.js`
}
return "assets/js/[name].js"
},
chunkFileNames: "assets/js/[name].js",
assetFileNames(assetInfo) {
const extension = assetInfo.name?.split(".").pop()
switch (extension) {
case "css":
return "assets/css/[name][extname]"
case "woff":
case "woff2":
return "assets/fonts/[name][extname]"
default:
return "assets/[name][extname]"
}
},
},
},
},
plugins: [
akte({ app }),
{
name: "markdown:watch",
configureServer(server) {
// Hot reload on Markdown updates
server.watcher.add("data/notes")
server.watcher.on("change", (path) => {
if (path.endsWith(".md")) {
app.clearCache(true)
server.ws.send({
type: "full-reload",
})
}
})
},
},
],
test: {
include: ["../test/**/*.test.ts"],
coverage: {
reporter: ["lcovonly", "text"],
},
},
})