-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
47 lines (45 loc) · 1.73 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
import { defineConfig, type UserConfig } from "vite"
import { qwikVite } from "@builder.io/qwik/optimizer"
import { qwikCity } from "@builder.io/qwik-city/vite"
import tsconfigPaths from "vite-tsconfig-paths"
import pkg from "./package.json"
const { dependencies = {}, devDependencies = {} } = pkg as any as {
dependencies: Record<string, string>
devDependencies: Record<string, string>
[key: string]: unknown
}
export default defineConfig(({ command, mode }): UserConfig => {
return {
plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
// This tells Vite which dependencies to pre-build in dev mode.
optimizeDeps: {
// Put problematic deps that break bundling here, mostly those with binaries.
// For example ['better-sqlite3'] if you use that in server functions.
exclude: [],
},
// This tells Vite how to bundle the server code.
ssr:
command === "build" && mode === "production"
? {
// All dev dependencies should be bundled in the server build
noExternal: Object.keys(devDependencies),
// Anything marked as a dependency will not be bundled
// These should only be production binary deps (including deps of deps), CLI deps, and their module graph
// If a dep-of-dep needs to be external, add it here
// For example, if something uses `bcrypt` but you don't have it as a dep, you can write
// external: [...Object.keys(dependencies), 'bcrypt']
external: Object.keys(dependencies),
}
: undefined,
server: {
headers: {
"Cache-Control": "public, max-age=0",
},
},
preview: {
headers: {
"Cache-Control": "public, max-age=600",
},
},
}
})