-
-
Notifications
You must be signed in to change notification settings - Fork 616
Expand file tree
/
Copy pathvite.preload.config.ts
More file actions
37 lines (34 loc) · 1.15 KB
/
vite.preload.config.ts
File metadata and controls
37 lines (34 loc) · 1.15 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
import { type ConfigEnv, mergeConfig, type UserConfig } from 'vite';
import {
external,
getBuildConfig,
pluginHotRestart,
} from './vite.base.config.js';
export function getConfig(
forgeEnv: ConfigEnv<'build'>,
userConfig: UserConfig = {},
): UserConfig {
const { forgeConfigSelf, forgeConfig } = forgeEnv;
const isEsm = forgeConfig.outputFormat === 'es';
const config: UserConfig = {
build: {
copyPublicDir: false,
rollupOptions: {
external: [...external, 'electron/renderer'],
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
input: forgeConfigSelf.entry,
output: {
format: isEsm ? 'es' : 'cjs',
// It should not be split chunks.
inlineDynamicImports: true,
entryFileNames: isEsm ? '[name].mjs' : '[name].cjs',
chunkFileNames: isEsm ? '[name].mjs' : '[name].cjs',
assetFileNames: '[name].[ext]',
},
},
},
plugins: [pluginHotRestart('reload')],
};
const buildConfig = getBuildConfig(forgeEnv);
return mergeConfig(mergeConfig(buildConfig, config), userConfig);
}