forked from wangbin3162/bin-datav-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mts
107 lines (102 loc) · 2.6 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { loadEnv, defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import glsl from 'rollup-plugin-glsl'
function pathResolve(dir) {
return resolve(process.cwd(), '.', dir)
}
// const proxyAddress = {
// target: 'http://192.168.0.118:5850/',
// // target: 'http://192.168.0.121:8850/',
// changeOrigin: true,
// }
// https://vitejs.dev/config/
export default ({ mode }) => {
const dirRoot = process.cwd()
const env = loadEnv(mode, dirRoot)
return defineConfig({
base: env.VITE_PUBLIC_PATH + '/',
plugins: [
vue(),
glsl({
// By default, everything gets included
include: '**/*.glsl',
// Undefined by default
exclude: ['**/index.html'],
// Source maps are on by default
// sourceMap: false,
}),
],
server: {
host: '0.0.0.0',
port: 8086,
open: true,
proxy: {
// '/auth': proxyAddress,
// '/oauth': proxyAddress,
// '/user': proxyAddress,
// '/management': proxyAddress,
},
},
resolve: {
alias: {
'@': pathResolve('./src'),
},
},
optimizeDeps: {
include: [
'axios',
'vue',
'vue-router',
'pinia',
'dayjs',
'echarts',
'bin-ui-design',
'js-cookie',
'mockjs',
'brace',
'three',
'gsap',
],
exclude: [],
},
build: {
sourcemap: false,
outDir: 'docs',
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks(id) {
if (id.includes('/node_modules/')) {
// 设置需要独立打包的npm包
const expansions = [
'bin-ui-design',
'bin-datav',
'brace',
'particles.vue3',
'mockjs',
'three',
'gsap',
]
const c = expansions.find(exp => id.includes(`/node_modules/${exp}`))
if (c) {
return `chunk-${c}`
} else {
return 'vendor'
}
}
},
},
},
// Turning off brotliSize display can slightly reduce packaging time
brotliSize: false,
chunkSizeWarningLimit: 2000,
},
define: {
// enable hydration mismatch details in production build
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true',
},
})
}