-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.example.ts
71 lines (66 loc) · 2.43 KB
/
vite.config.example.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
71
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import path from 'path';
export default defineConfig({
plugins: [
vue(),
AutoImport({
// 目标文件
include: [
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/, // .vue
/\.md$/, // .md
],
// 全局引入插件
imports: [
// presets
'vue',
'vue-router',
// custom
{
'@vueuse/core': [
// named imports
'useMouse', // import { useMouse } from '@vueuse/core',
// alias
['useFetch', 'useMyFetch'], // import { useFetch as useMyFetch } from '@vueuse/core',
],
axios: [
// default imports
['default', 'axios'], // import { default as axios } from 'axios',
],
},
],
// eslint报错解决
eslintrc: {
enabled: false, // enabled为true时,会根据filepath生成一个eslint的配置文件。这个文件需要引入到eslint的配置文件中,需要更新配置文件的时候改为true。
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
},
// 解析器,例如element-plus的ElementPlusResolver
// see https://github.com/antfu/unplugin-auto-import/pull/23/
resolvers: [
/* ... */
],
// 声明文件生成位置和文件名称
dts: 'src/auto-import.d.ts',
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'tailwind-config': path.resolve(__dirname, './tailwind.config.js'),
},
},
server: {
proxy: {
'/api': {
target: 'http://host:port',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
});