-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathvite.config.ts
49 lines (47 loc) · 1.51 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
import { defineConfig, loadEnv } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import compressPlugin from 'vite-plugin-compression'
import AutoImport from 'unplugin-auto-import/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// 根据当前工作目录中的 `mode` 加载 .env 文件
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
const env = loadEnv(mode, process.cwd(), 'VITE')
return {
base: env.VITE_BASE,
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
extensions: ['.js', '.json', 'jsx', '.vue', '.ts'] // 使用路径别名时想要省略的后缀名,可以自己 增减
},
root: process.cwd(),
assetsInclude: ['./src/assets'],
plugins: [
vue(),
vueJsx({}),
compressPlugin({
threshold: 1024 * 1024 * 1
}),
AutoImport({
imports: ['vue', 'vue-router', 'pinia'], // 你想要自动导入的库
// 你可以在这里添加更多的配置选项
dts: './auto-imports.d.ts'
}),
Components({
resolvers: [NaiveUiResolver()]
})
],
define: {
__APP_ENV__: env.APP_ENV
},
build: {
emptyOutDir: true,
chunkSizeWarningLimit: 1000
}
}
})