-
Notifications
You must be signed in to change notification settings - Fork 35
/
vite.preload.config.ts
43 lines (41 loc) · 1.08 KB
/
vite.preload.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
import type { ConfigEnv, UserConfig } from 'vite'
import { defineConfig, mergeConfig } from 'vite'
import { configDefaults } from 'vitest/config'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import {
getBuildConfig,
getBuildDefine,
external,
pluginHotRestart,
} from './vite.base.config'
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'build'>
const define = getBuildDefine(forgeEnv)
const { root, mode, forgeConfigSelf } = forgeEnv
const config: UserConfig = {
root,
mode,
base: './',
build: {
lib: {
entry: forgeConfigSelf?.entry ?? 'src/preload.ts',
fileName: () => '[name].js',
formats: ['cjs'],
},
rollupOptions: {
external,
},
},
resolve: {
// Load the Node.js entry.
mainFields: ['module', 'jsnext:main', 'jsnext'],
},
plugins: [pluginHotRestart('restart'), viteTsconfigPaths()],
worker: {
plugins: () => [viteTsconfigPaths()],
},
define,
}
return mergeConfig(getBuildConfig(forgeEnv), config)
})