-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mts
60 lines (56 loc) · 1.38 KB
/
vite.config.mts
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
import type { PluginOption } from 'vite';
import { defineConfig, loadEnv, UserConfigExport } from 'vite';
import checker from 'vite-plugin-checker';
import handlebars from 'vite-plugin-handlebars';
import dns from 'dns';
const hash = Math.floor(Math.random() * 90000) + 10000;
dns.setDefaultResultOrder('verbatim');
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const handlebarsConfig = {
context: {
isLocal: mode === env.VITE_MODE
}
} as any;
const config: UserConfigExport = {
base: './',
server: {
port: 9000
},
build: {
rollupOptions: {
input: {
index: './index.html',
'root-config': './src/main.js'
},
output: {
format: 'system',
entryFileNames: `[name]-${hash}.js`,
assetFileNames: `assets/[name]-${hash}[ext]`,
// assetFileNames: 'assets/[name][ext]',
globals: {
'single-spa': 'singleSpa',
'single-spa-layout': 'singleSpaLayout'
}
},
preserveEntrySignatures: 'strict',
external: ['vue', 'single-spa', 'single-spa-layout']
}
},
plugins: [
checker({
typescript: true
}),
handlebars(handlebarsConfig) as unknown as PluginOption
// {
// name: 'vite-plugin-build-rm-file',
// apply: 'build',
// enforce: 'post',
// closeBundle() {
// fs.unlinkSync(`${env.VITE_OUTDIR}/index.js`);
// }
// }
]
};
return config;
});