-
Notifications
You must be signed in to change notification settings - Fork 18
/
vite.config.js
105 lines (101 loc) · 2.76 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import styleImport from 'vite-plugin-style-import' //按需加载样式
import SvgIconsPlugin from 'vite-plugin-svg-icons' // 打包生成svg雪碧图
import DC from '@dvgis/vite-plugin-dc'
// import ViteComponents, { AntDesignVueResolver } from 'vite-plugin-components'
// import Components from 'unplugin-vue-components/vite'
// import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, __dirname) // 获取全局变量
const isBuild = command === 'build'
return {
base: env.VITE_BASE_PATH,
css: {
preprocessorOptions: {
less: {
modifyVars: {},
javascriptEnabled: true,
},
},
},
assetsInclude: ['svg'],
plugins: [
vue(),
styleImport({
libs: [
{
libraryName: 'ant-design-vue',
esModule: true,
resolveStyle: (name) => {
return `ant-design-vue/es/${name}/style/index`
},
},
],
}),
SvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icon')],
svgoOptions: isBuild,
// default
symbolId: 'icon-[dir]-[name]',
}),
DC(),
],
build: {
rollupOptions: {
output: {
manualChunks: {
echarts: ['echarts'],
},
},
external: ['vue']
},
terserOptions: {
ecma: undefined,
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log'],
},
// ecma: undefined,
// warnings: false,
// parse: {},
// compress: {
// drop_console: true, // 禁用console.* 功能
// drop_debugger: false, //移除debugger语句
// pure_funcs: ['console.log'], // 移除被禁用的console.log语句
// },
},
},
server: {
//本地服务
port: 3001, //端口号
open: true, //启动时是否自动打开
proxy: {
'/vue-manage': {
target: env.VITE_BASE_URL,
changeOrigin: true,
},
'/local-test': {
target: env.VITE_LOCAL_TEST_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/local-test/, ''),
},
},
},
clearScreen: false, // vite清屏不清除控制台打印的信息
// logLevel:'error',
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
'@': path.resolve(__dirname, 'src'),
},
},
optimizeDeps: {
include: ['vue-i18n'],
},
logLevel: 'info',
}
})