提交 | 用户 | 时间
|
b0367d
|
1 |
const { resolve } = require('path') |
H |
2 |
import {defineConfig} from 'vite' |
|
3 |
import vue from '@vitejs/plugin-vue' |
|
4 |
|
|
5 |
export default defineConfig({ |
|
6 |
server: { |
|
7 |
host: '0.0.0.0', |
|
8 |
port: 3000, |
|
9 |
open: true, |
|
10 |
proxy: { |
|
11 |
['/proxy-api']: { |
|
12 |
target: 'http://localhost:8083', |
|
13 |
changeOrigin: true, |
|
14 |
rewrite: (path) => path.replace(`/proxy-api`, ''), |
|
15 |
} |
|
16 |
}, |
|
17 |
disableHostCheck: true |
|
18 |
}, |
|
19 |
base: '', |
|
20 |
plugins: [ |
|
21 |
vue(), |
|
22 |
], |
|
23 |
resolve: { |
|
24 |
alias: { |
|
25 |
// 设置路径 这里resolve和join可自行选用 |
|
26 |
'~': resolve(__dirname, './'), |
|
27 |
// 设置别名 |
|
28 |
'@': resolve(__dirname, './src') |
|
29 |
}, |
|
30 |
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] |
|
31 |
}, |
d36528
|
32 |
build: { |
H |
33 |
emptyOutDir: true, |
|
34 |
cssCodeSplit: false, |
|
35 |
outDir: '../../iailab-doc-wiki/src/main/resources/dist', |
|
36 |
rollupOptions: { |
|
37 |
input: { |
|
38 |
main: resolve(__dirname, 'doc-wiki.html'), |
|
39 |
}, |
|
40 |
output: { |
|
41 |
// 拆分包 |
|
42 |
manualChunks: (id) => { |
|
43 |
if (id.includes('node_modules')) { |
|
44 |
const module = id.toString().split('node_modules/')[1].split('/')[0]; |
|
45 |
if (['mermaid', 'highlight.js', 'katex', 'zrender', 'vant'].includes(module)) { |
|
46 |
return module; |
|
47 |
} |
|
48 |
if (module === '@vue') return 'vue'; |
|
49 |
if (module === '@wangeditor') return 'wangeditor'; |
|
50 |
if (module.indexOf('markmap') === 0) return 'markmap'; |
|
51 |
if (module.indexOf('markdown') === 0) return 'markdown'; |
|
52 |
// 不可拆分:echarts、element-plus |
|
53 |
if (!['echarts', 'element-plus'].includes(module)) { |
|
54 |
return 'vendor'; |
|
55 |
} |
|
56 |
} |
|
57 |
}, |
|
58 |
assetFileNames: 'assets/[name].[hash].[ext]', |
|
59 |
} |
|
60 |
} |
|
61 |
}, |
b0367d
|
62 |
}); |