-
Notifications
You must be signed in to change notification settings - Fork 170
/
vite.config.js
47 lines (42 loc) · 1.01 KB
/
vite.config.js
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
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import path from 'path';
import { loadEnv } from 'vite';
const envLocal = loadEnv(process.env.NODE_ENV, process.cwd());
const isDev = process.env.NODE_ENV === 'development';
const toConfig = () => {
const config = {
plugins: [
vue(),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/svg-icons')],
symbolId: 'icon-[dir]-[name]',
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
};
if (isDev) {
config.server = {
https: {
key: './cert/localhost.key',
cert: './cert/localhost.crt',
},
host: true,
port: '30000',
proxy: {
'/api': {
target: envLocal.VITE_API_PROXY,
changeOrigin: true,
},
},
};
}
return config;
};
// https://vitejs.dev/config/
export default defineConfig(toConfig());