-
Notifications
You must be signed in to change notification settings - Fork 241
/
vite.config.ts
64 lines (63 loc) · 1.79 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
58
59
60
61
62
63
64
import { fileURLToPath, URL } from 'node:url';
import path from 'node:path';
import { defineConfig } from 'vite';
import ViteProxyServer from './viteUtil/viteProxyServer/vite-plugin-proxy-server';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VueHooksPlusResolver } from '@vue-hooks-plus/resolvers';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import IconsResolver from 'unplugin-icons/resolver';
import Icons from 'unplugin-icons/vite';
import vue from '@vitejs/plugin-vue';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
const OpenSSl = (process.env?.npm_lifecycle_event === 'dev-ssl');
// https://vitejs.dev/config/
export default defineConfig({
server: {
host: OpenSSl,
https: OpenSSl && {
key: fs.readFileSync('viteUtil/cert/key.pem'),
cert: fs.readFileSync('viteUtil/cert/cert.pem')
},
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
}
},
plugins: [
vue(),
AutoImport({
imports: ['vue'],
resolvers: [
ElementPlusResolver(),
VueHooksPlusResolver(),
// 自动导入图标组件
IconsResolver({
prefix: 'Icon'
})
]
}),
Components({
resolvers: [
// 自动注册图标组件
IconsResolver({
enabledCollections: ['ep']
}),
// 自动导入 Element Plus 组件
ElementPlusResolver()
]
}),
Icons({
autoInstall: true
}),
// 本地代理服务
ViteProxyServer()
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
pages: path.resolve(__dirname, './src/pages')
}
}
});