-
Notifications
You must be signed in to change notification settings - Fork 19
/
vite.config.ts
70 lines (66 loc) · 1.92 KB
/
vite.config.ts
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
import { URL, fileURLToPath } from 'node:url'
import { type ConfigEnv, defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import VueDevTools from 'vite-plugin-vue-devtools'
import UnoCSS from 'unocss/vite'
import { visualizer } from 'rollup-plugin-visualizer'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { createHtmlPlugin } from 'vite-plugin-html'
import { vitePluginForArco } from '@arco-plugins/vite-vue'
import AutoImport from 'unplugin-auto-import/vite'
import { VitePWA } from 'vite-plugin-pwa'
import { getBuild, getPwaOptions } from './__vite'
// https://vitejs.dev/config/
export default ({ mode }: ConfigEnv) =>
defineConfig({
plugins: [
vue(),
vueJsx(),
VueDevTools(),
UnoCSS(),
visualizer(),
// vueSetupExtend(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [fileURLToPath(new URL('./src/assets/icons', import.meta.url))],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
VitePWA(getPwaOptions),
vitePluginForArco({
style: 'css',
}),
AutoImport({
// 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
imports: ['vue', 'vue-i18n'],
}),
createHtmlPlugin({
inject: {
data: {
title: getViteEnv(mode, 'VITE_APP_TITLE'),
},
},
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
// i18n
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
},
},
server: {
host: '0.0.0.0',
port: 9876,
// open: true,
},
build: getBuild(),
esbuild: {
drop: ['console', 'debugger'],
sourcemap: false,
},
})
function getViteEnv(mode: string, target: string) {
return loadEnv(mode, import.meta.url)[target]
}