forked from mvpyb/vite-element-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
90 lines (81 loc) · 2.29 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import { getEnv, regExps } from './config'
import { composePlugins } from './config/plugins'
function resolve( dir ) {
return path.join( __dirname, dir )
}
// https://vitejs.dev/config/
export default defineConfig( ( { command, mode } ) => {
const root = process.cwd()
const env = getEnv( loadEnv( mode, process.cwd() ) )
const { VITE_PORT, VITE_PROXY_DOMAIN, VITE_PROXY_DOMAIN_REAL, VITE_LEGACY } = env
return {
root,
base : './', //
resolve : {
alias : {
'@' : resolve( 'src' )
},
extensions : ['.js', '.json', '.ts', '.vue']
},
plugins : composePlugins( command, VITE_LEGACY ),
server : {
host : '0.0.0.0',
port : VITE_PORT || 9527,
https : false,
open : false,
proxy : {
[VITE_PROXY_DOMAIN] : {
target : VITE_PROXY_DOMAIN_REAL,
ws : false,
changeOrigin : true,
rewrite : ( path ) => regExps( path, VITE_PROXY_DOMAIN )
}
}
},
define : {
// https://vue-i18n.intlify.dev/guide/advanced/optimization.html#quasar-cli
// 消除 vue-i18n 警告
__VUE_I18N_FULL_INSTALL__ : true,
__VUE_I18N_LEGACY_API__ : false,
__INTLIFY_PROD_DEVTOOLS__ : false,
__APP_INFO__ : JSON.stringify( {
version : '3.0.0'
} )
},
build : {
path : './',
sourcemap : false,
brotliSize : false,
chunkSizeWarningLimit : 2500,
// minify: 'terser',
// terserOptions: {
// compress: {
// drop_console: true,
// drop_debugger: true
// }
// },
rollupOptions : {
output : {
manualChunks( id ) {
if ( id.includes( 'node_modules' ) ) {
return id
.toString()
.split( 'node_modules/' )[1]
.split( '/' )[0]
.toString()
}
},
chunkFileNames : ( chunkInfo ) => {
const facadeModuleId = chunkInfo.facadeModuleId
? chunkInfo.facadeModuleId.split( '/' )
: []
const fileName = facadeModuleId[facadeModuleId.length - 2] || '[name]'
return `js/${fileName}/[name].[hash].js`
}
}
}
}
}
} )