forked from x007xyz/fly-cut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
74 lines (73 loc) · 2.19 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
65
66
67
68
69
70
71
72
73
74
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';
import VitePluginVueDevtools from 'vite-plugin-vue-devtools';
// 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: {
port: 4008,
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: [
VitePluginVueDevtools(),
vue(),
AutoImport({
imports: ['vue'],
resolvers: [
ElementPlusResolver(),
VueHooksPlusResolver(),
// 自动导入图标组件
IconsResolver({
prefix: 'Icon'
})
],
eslintrc: { // 生成eslint的配置文件,需要在eslint配置中导入
enabled: true, // Default `false`
globalsPropValue: 'readonly' // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
}
}),
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')
}
},
build: {
sourcemap: true
}
});