-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathvite.preload.config.ts
44 lines (39 loc) · 1.21 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
44
import type { ConfigEnv, UserConfig } from 'vite'
import { defineConfig, mergeConfig } from 'vite'
import {
getBuildConfig,
external,
pluginHotRestart,
} from './vite.base.config'
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'build'>
const { forgeConfigSelf } = forgeEnv
const config: UserConfig = {
build: {
chunkSizeWarningLimit: 2000,
rollupOptions: {
external,
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
input: forgeConfigSelf.entry,
output: {
format: 'cjs',
// It should not be split chunks.
inlineDynamicImports: true,
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name].[ext]',
},
onwarn(warning, warn) {
// Suppress "Module level directives cause errors when bundled" warnings
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return
}
warn(warning)
},
},
},
plugins: [pluginHotRestart('reload')],
}
return mergeConfig(getBuildConfig(forgeEnv), config)
})