-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
104 lines (100 loc) · 2.9 KB
/
Copy pathvite.config.ts
File metadata and controls
104 lines (100 loc) · 2.9 KB
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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import viteCompression from 'vite-plugin-compression'
const proxyUrl = 'http://192.168.0.112:8857/duty-service-provider'
export default defineConfig({
build: {
outDir: 'dist',
assetsDir: 'static',
target: ['chrome78'],
chunkSizeWarningLimit: 1000,
sourcemap: false,
cssCodeSplit: true,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true, //打包时删除 debugger
},
output: {
comments: true, // 去掉注释内容
},
},
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) return
// Vue 核心生态
if (/node_modules\/(@vue|vue|vue-router|pinia|vue-i18n)\//.test(id)) {
return 'vue-vendor'
}
// Naive UI 组件库
if (/node_modules\/naive-ui\//.test(id)) {
return 'naive-ui'
}
// ECharts 图表库
if (/node_modules\/echarts\//.test(id)) {
return 'echarts'
}
// lodash 工具库
if (/node_modules\/lodash\//.test(id)) {
return 'lodash'
}
// 其他第三方库合并为一个 chunk
const match = id.toString().split('node_modules/')[1]?.split('/')[0]
if (match) {
return `vendor-${match}`
}
},
},
},
reportCompressedSize: false
},
optimizeDeps: {
include: [
'naive-ui',
'vue',
'vue-router',
'pinia',
'vue-i18n',
'echarts',
'lodash',
'@vueuse/core',
],
},
base: './',
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
plugins: [
vue(),
vueJsx(),
viteCompression(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'vue': 'vue/dist/vue.esm-bundler.js',
},
},
server: {
port: 3031,
host: '0.0.0.0',
open: true,
hmr: {
overlay: true,
},
proxy: {
'/duty-service-provider': {
target: proxyUrl,
changeOrigin: true,
rewrite: (p) => p.replace(/^\/duty-service-provider/, '')
},
},
},
})