-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathvite.renderer.config.ts
More file actions
85 lines (82 loc) · 2.44 KB
/
Copy pathvite.renderer.config.ts
File metadata and controls
85 lines (82 loc) · 2.44 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
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
82
83
84
85
// @ts-ignore: No types available
import { lezer } from '@lezer/generator/rollup'
import type { ConfigEnv, UserConfig } from 'vite'
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import topLevelAwait from 'vite-plugin-top-level-await'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import {
createCustomLogger,
indexHtmlCsp,
isIgnoredWatchPath,
pluginExposeRenderer,
} from './vite.base.config'
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'renderer'>
const { root, mode, forgeConfigSelf } = forgeEnv
const name = forgeConfigSelf?.name ?? 'main_window'
return {
customLogger: createCustomLogger(),
root,
mode,
base: './',
server: {
watch: {
ignored: isIgnoredWatchPath,
},
},
build: {
outDir: `.vite/renderer/${name}`,
target: 'es2022',
},
// Three 0.184 uses class static blocks that esbuild can minify into
// anonymous class expressions which crash during startup.
esbuild: {
supported: {
'class-static-blocks': false,
},
},
// Needed for electron-forge (in npm run tron:start). Keeping the
// renderer-only deps explicit avoids a cold-start optimizer reload while
// Electron is already showing the window.
optimizeDeps: {
include: [
'@lezer/lr',
'node:path',
'path',
'vite-plugin-node-polyfills/shims/buffer',
'vite-plugin-node-polyfills/shims/global',
'vite-plugin-node-polyfills/shims/process',
],
esbuildOptions: { target: 'es2022' },
},
plugins: [
nodePolyfills({
include: ['path'],
}),
indexHtmlCsp(mode !== 'development'),
pluginExposeRenderer(name),
viteTsconfigPaths(),
lezer(),
// Needed for electron-builder (in npm run tronb:vite scripts)
topLevelAwait({
// The export name of top-level await promise for each chunk module
promiseExportName: '__tla',
// The function to generate import names of top-level await promise in each chunk module
promiseImportName: (i) => `__tla_${i}`,
}),
],
worker: {
plugins: () => [viteTsconfigPaths()],
},
resolve: {
preserveSymlinks: true,
alias: {
'@kittycad/codemirror-lsp-client':
'/packages/codemirror-lsp-client/src',
},
},
clearScreen: false,
} as UserConfig
})