-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathvite.main.config.ts
39 lines (36 loc) · 1.09 KB
/
vite.main.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
import type { ConfigEnv, Plugin, PluginOption, UserConfig } from 'vite';
import { defineConfig, mergeConfig } from 'vite';
import { getBuildConfig, getBuildDefine, external, pluginHotRestart } from './vite.base.config.js';
console.log("vite.main.config.ts");
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'build'>;
const { forgeConfigSelf } = forgeEnv;
const define = getBuildDefine(forgeEnv);
const plugins: PluginOption[] = []
if(process.env.NODE_ENV !== 'test') {
plugins.push(pluginHotRestart('restart'))
}
const config: UserConfig = {
build: {
lib: {
entry: forgeConfigSelf?.entry,
fileName: () => '[name].js',
formats: ['es'],
},
rollupOptions: {
external,
},
},
// main process static assets
// ./assets dir is copied to .vite/build dir
publicDir: './assets',
plugins,
define,
resolve: {
// Load the Node.js entry.
mainFields: ['module', 'jsnext:main', 'jsnext'],
},
};
return mergeConfig(getBuildConfig(forgeEnv), config);
});