-
Notifications
You must be signed in to change notification settings - Fork 529
/
vite.config.ts
58 lines (54 loc) · 1.62 KB
/
vite.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import path from 'node:path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
// import tsconfigPaths from 'vite-tsconfig-paths';
import config from '../.deploy.config.js';
import { licenseBanner } from '../scripts/scripts-utils.js';
const baseConfig = {
build: {
emptyOutDir: true,
outDir: '../dist/panel',
minify: true,
sourcemap: undefined, // placeholder
// generate manifest.json in outDir
manifest: true,
rollupOptions: {
input: undefined, //placeholder
output: {
banner: licenseBanner('..'),
//Adding hash to help with cache busting
entryFileNames: `[name]-[hash].js`,
chunkFileNames: `[name]-[hash].js`,
assetFileNames: '[name]-[hash].[ext]',
}
},
},
server: {
origin: undefined, //placeholder
},
base: '',
clearScreen: false,
plugins: [
// tsconfigPaths({
// projects: ['./', '../shared']
// }),
react()
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@shared": path.resolve(__dirname, "../shared"),
},
},
}
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
if (command === 'serve') {
baseConfig.server.origin = config.panelViteUrl;
baseConfig.build.rollupOptions.input = './src/main.tsx'; // overwrite default .html entry
return baseConfig;
} else {
baseConfig.build.sourcemap = true;
return baseConfig;
}
})