-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
executable file
·112 lines (110 loc) · 3.56 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
106
107
108
109
110
111
112
import path from 'path'
import { vitePluginForArco } from '@arco-plugins/vite-vue'
import vue from '@vitejs/plugin-vue'
import jsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import { ElementPlusResolver, ArcoResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { VueRouterAutoImports } from 'unplugin-vue-router'
import { defineConfig, loadEnv } from 'vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import VueDevTools from 'vite-plugin-vue-devtools'
export default ({ mode }) =>
defineConfig({
base: loadEnv(mode, process.cwd()).VITE_PUBLIC_PATH,
define: {
'process.platform': null,
'process.version': null
},
clearScreen: false,
plugins: [
// VueDevTools(),
vue(),
jsx(),
vitePluginForArco({ style: 'css' }),
Icons({ autoInstall: true }),
AutoImport({
imports: ['vue', /** 'vue-router', */ 'pinia', VueRouterAutoImports],
resolvers: [
// 按需加载 Arco
ArcoResolver(),
// 按需加载 Icons
IconsResolver({ prefix: 'Icon' }),
// 按需加载 ElementPlus
ElementPlusResolver()
],
eslintrc: {
enabled: true,
filepath: './.eslintrc-auto-import.json',
globalsPropValue: true
}
}),
Components({
dts: false,
resolvers: [
// 按需加载 Arco
ArcoResolver({ sideEffect: true }),
// 按需加载 Icons
IconsResolver({ enabledCollections: ['ep'] }),
// 按需加载 ElementPlus
ElementPlusResolver()
]
}),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
symbolId: 'icon-[dir]-[name]'
})
],
server: {
// host: '0.0.0.0', // 设置外网访问
port: 9529, // 服务器端口
open: false, // 启动时自动在浏览器中打开应用程序
cors: true // 跨域
},
build: {
minify: 'esbuild',
// chunk 大小警告的限制(以 kbs 为单位)
chunkSizeWarningLimit: 2000,
// 指定生成静态资源的存放路径
assetsDir: 'static/assets',
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name].[hash].js',
entryFileNames: 'static/js/[name].[hash].js',
assetFileNames: 'static/[ext]/[name].[hash].[ext]',
manualChunks: {
vue: ['vue', 'vue-router'],
echarts: ['echarts'],
editorWorker: ['monaco-editor/esm/vs/editor/editor.worker'],
jsonWorker: ['monaco-editor/esm/vs/language/json/json.worker'],
htmlWorker: ['monaco-editor/esm/vs/language/html/html.worker']
}
}
}
},
resolve: {
alias: {
// eslint-disable-next-line unicorn/prefer-module
'~': path.resolve(__dirname, './'),
// eslint-disable-next-line unicorn/prefer-module
'@': path.resolve(__dirname, 'src')
},
extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/styles/variables.scss";'
}
}
},
optimizeDeps: {
include: [
'monaco-editor/esm/vs/editor/editor.worker',
'monaco-editor/esm/vs/language/json/json.worker',
'monaco-editor/esm/vs/language/html/html.worker'
]
}
})