-
Notifications
You must be signed in to change notification settings - Fork 477
Expand file tree
/
Copy pathvite.config.ts
More file actions
86 lines (84 loc) · 2.14 KB
/
vite.config.ts
File metadata and controls
86 lines (84 loc) · 2.14 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
import path from 'node:path'
import { fileURLToPath, URL } from 'node:url'
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { defineConfig, loadEnv } from 'vite'
// https://vite.dev/config/#using-environment-variables-in-config
export default defineConfig(({ mode }) => {
const cwd = fileURLToPath(new URL('./', import.meta.url))
const viteEnv = loadEnv(mode, cwd) as ImportMetaEnv
return {
resolve: {
alias: {
'@': path.resolve(cwd, 'src'),
},
},
plugins: [
vue(),
tailwindcss(),
AutoImport({
imports: [
'vue',
'vue-router',
'pinia',
'vue-i18n',
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar',
],
},
],
resolvers: [
IconsResolver({
prefix: 'Icon',
enabledCollections: ['ri', 'mdi', 'ic', 'mage', 'uil'],
}),
],
}),
Icons({
compiler: 'vue3',
}),
Components({
dirs: [],
resolvers: [
NaiveUiResolver(),
IconsResolver({
prefix: 'Icon',
enabledCollections: ['ri', 'mdi', 'ic', 'mage', 'uil'],
}),
],
}),
],
server: {
host: '0.0.0.0',
port: 1002,
open: false,
proxy: {
'/api': {
target: viteEnv.VITE_APP_API_BASE_URL,
changeOrigin: true, // 允许跨域
rewrite: path => path.replace('/api/', '/'),
},
'/uploads': {
target: viteEnv.VITE_APP_API_BASE_URL,
changeOrigin: true, // 允许跨域
},
},
},
build: {
reportCompressedSize: false,
sourcemap: false,
commonjsOptions: {
ignoreTryCatch: false,
},
},
}
})