-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (53 loc) · 1.39 KB
/
Copy pathvite.config.ts
File metadata and controls
55 lines (53 loc) · 1.39 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
import path from 'node:path';
import process from 'node:process';
import vue from '@vitejs/plugin-vue';
import { defineConfig, loadEnv } from 'vite';
import AutoImport from 'unplugin-auto-import/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const apiPrefix = env.VITE_API_URL || '/dev-api';
const proxyTarget = env.VITE_API_PROXY_TARGET || 'http://127.0.0.1:6039';
const proxy = apiPrefix.startsWith('/')
? {
[apiPrefix]: {
target: proxyTarget,
changeOrigin: true,
rewrite: (requestPath: string) => requestPath.replace(new RegExp(`^${apiPrefix}`), ''),
},
}
: undefined;
return {
plugins: [
vue(),
AutoImport({
imports: ['vue'],
resolvers: [ElementPlusResolver()],
dts: 'types/auto-imports.d.ts',
}),
Components({
resolvers: [ElementPlusResolver()],
dts: 'types/components.d.ts',
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: '',
},
},
},
server: {
headers: {
'Cache-Control': 'no-store',
},
proxy,
},
};
});