-
Notifications
You must be signed in to change notification settings - Fork 39
/
vite.config.ts
48 lines (44 loc) · 1.33 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
import Icons from "unplugin-icons/vite"
import Inspect from "vite-plugin-inspect"
import { sveltekit } from "@sveltejs/kit/vite"
import { purgeCss } from "vite-plugin-tailwind-purgecss"
import { nodePolyfills } from "vite-plugin-node-polyfills"
import { defineConfig, loadEnv, type PluginOption } from "vite"
export default defineConfig(config => {
const {
INSPECT,
NODE_ENV,
ENVIRONMENT,
PORT = process.env.PORT || 5173
} = loadEnv(config.mode, process.cwd(), "") as unknown as EnvironmentVariables
const plugins = [
purgeCss(),
nodePolyfills({
include: ["stream"],
globals: { process: true, Buffer: true, global: true }
}),
sveltekit(),
Icons({ compiler: "svelte", autoInstall: true })
] satisfies Array<PluginOption>
if (INSPECT === "true") plugins.push(Inspect())
// we want logs to show up in preview deployments for debugging
const dropLogStatements = config.mode === "build" && ENVIRONMENT === "production"
return {
plugins,
build: { target: "es2020" },
esbuild: {
drop: dropLogStatements ? ["console", "debugger"] : []
},
optimizeDeps: {
exclude: ["@tanstack/svelte-query-devtools"]
},
ssr: {
external: []
},
server: {
port: Number(PORT)
},
experimental: {},
test: { include: ["src/**/*.{test,spec}.{js,ts}"] }
}
})