-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.config.ts
55 lines (53 loc) · 1.67 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
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
import pkgJson from "./package.json"
const isDevelopment = (mode) => mode === "development"
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }) => ({
build: {
outDir: "build",
sourcemap: isDevelopment(mode) || "hidden",
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
output: {
manualChunks: (id) => (id.includes("node_modules") ? "vendor" : null),
},
external: ["virtual:terminal"],
},
},
esbuild: {
supported: {
"top-level-await": true,
},
},
plugins: [
react(),
// In dev, let console.log go to terminal and console output. `console` arg
// for vite-plugin-terminal doesn't work . See this issue.
// https://github.com/patak-dev/vite-plugin-terminal/issues/23
...[
isDevelopment(mode) &&
(await import("vite-plugin-terminal")).default({
output: ["terminal", "console"],
}),
],
],
define: {
global: "globalThis",
"import.meta.env.APP_DESCRIPTION": JSON.stringify(pkgJson.description),
"import.meta.env.APP_VERSION": JSON.stringify(pkgJson.version),
},
resolve: {
alias: {
http: "rollup-plugin-node-polyfills/polyfills/http",
https: "rollup-plugin-node-polyfills/polyfills/http",
stream: "rollup-plugin-node-polyfills/polyfills/stream",
util: "rollup-plugin-node-polyfills/polyfills/util",
zlib: "rollup-plugin-node-polyfills/polyfills/zlib",
process: "rollup-plugin-node-polyfills/polyfills/process-es6",
buffer: "rollup-plugin-node-polyfills/polyfills/buffer-es6",
},
},
}))