forked from ttk-cli/uni-vue3-vite-ts-pinia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
57 lines (55 loc) · 1.36 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
import { resolve } from 'node:path';
import uni from '@dcloudio/vite-plugin-uni';
import AutoImportTypes from 'auto-import-types';
import PiniaAutoRefs from 'pinia-auto-refs';
import Unocss from 'unocss/vite';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';
import env from './src/config/env';
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
plugins: [
AutoImportTypes(),
PiniaAutoRefs(),
AutoImport({
dts: 'src/auto-imports.d.ts',
imports: [
'vue',
'uni-app',
'pinia',
{
'@/helper/pinia-auto-refs': ['useStore']
}
],
exclude: ['createApp'],
eslintrc: {
enabled: true
}
}),
Components({
extensions: ['vue'],
dts: 'src/components.d.ts'
}),
uni(),
Unocss()
],
server: {
open: true, // 自动打开
base: './ ', // 生产环境路径
proxy: {
// 本地开发环境通过代理实现跨域,生产环境使用 nginx 转发
// 正则表达式写法
'^/api': {
target: env.apiBaseUrl, // 后端服务实际地址
changeOrigin: true, // 开启代理
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
});