-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
64 lines (63 loc) · 2.02 KB
/
vite.config.js
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
61
62
63
64
/*
* @FilePath: /Users/i104/vite3/vite.config.js
* @author: dongyang(yang.dong@derbysoft.net)
*/
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolveRootPath } from './utils/path';
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: [
{ find: 'src', replacement: resolveRootPath('src') },
{ find: 'assets', replacement: resolveRootPath('src/assets') },
{ find: 'components', replacement: resolveRootPath('src/components') },
{ find: 'config', replacement: resolveRootPath('src/config') },
{ find: 'enum', replacement: resolveRootPath('src/enum') },
{ find: 'layout', replacement: resolveRootPath('src/layout') },
{ find: 'routes', replacement: resolveRootPath('src/routes') },
{ find: 'stores', replacement: resolveRootPath('src/stores') },
{ find: 'styles', replacement: resolveRootPath('src/styles') },
{ find: 'utils', replacement: resolveRootPath('src/utils') },
{ find: 'views', replacement: resolveRootPath('src/views') },
]
},
build: {
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
// 解决打包时Some chunks are larger警告
// eslint-disable-next-line consistent-return
manualChunks(id) {
if (id.includes('node_modules')) {
return id
.toString()
.split('node_modules/')[1]
.split('/')[0]
.toString();
}
}
}
}
},
esbuild: {
treeShaking: true,
drop: ['debugger', 'console']
},
plugins: [react()],
server: {
hmr: {
overlay: false // 禁止服务器错误遮罩
},
port: 8888,
// proxy: {
// '/test0': {
// target: 'https://www.baidu.com',
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api\/test0/, ''),
// }
// }
}
})