-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.mts
56 lines (51 loc) · 1.14 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
import fs from 'fs';
import type { PluginOption } from 'vite';
import { defineConfig, loadEnv, UserConfigExport } from 'vite';
import handlebars from 'vite-plugin-handlebars';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const config: UserConfigExport = {
base: './',
server: {
port: 9000
},
build: {
rollupOptions: {
input: {
index: './index.html',
'root-config': './src/main.ts'
},
output: {
format: 'system',
entryFileNames: '[name].js',
assetFileNames: 'assets/[name][ext]',
globals: {
'single-spa': 'singleSpa',
'single-spa-layout': 'singleSpaLayout'
}
},
preserveEntrySignatures: 'strict',
external: ['single-spa', 'single-spa-layout']
}
},
plugins: [
handlebars({
context: {
isLocal: mode === 'development'
}
}) as unknown as PluginOption,
{
name: 'vite-plugin-build-rm-file',
apply: 'build',
enforce: 'post',
closeBundle() {
fs.unlinkSync(`${env.VITE_OUTDIR}/index.js`);
}
}
]
};
if (mode === 'docs') {
config.build.outDir = env.VITE_OUTDIR;
}
return config;
});