-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathvite.config.js
More file actions
28 lines (28 loc) · 834 Bytes
/
vite.config.js
File metadata and controls
28 lines (28 loc) · 834 Bytes
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
/*
* @Author: Ryanuo
* @Date: 2022-07-24 11:20:59
* @LastEditors: ryanuo
* @Github: https://github.com/ryanuo
* @LastEditTime: 2023-07-01 10:28:58
* @FilePath: \blazeB2\vite.config.js
*/
import { defineConfig, loadEnv } from 'vite'
import { plugins, build, server, resolveC, cssStyl } from './src/config'
export default ({ mode }) => {
function getEnv(key) { // 定义获取环境变量的方法
return loadEnv(mode, process.cwd(), '')[key] // 第三个参数非常重要,下面有详解
}
return defineConfig({
base: getEnv('VUE_APP_PUBLICPATH'), // 读取环境变量
publicDir: 'public',
css: cssStyl,
optimizeDeps: {
exclude: ['__INDEX__'] // 排除 __INDEX__
},
plugins: plugins(mode),
build,
envPrefix: ['VUE_APP_'], // 很重要
resolve: resolveC,
server
})
}