forked from zhongyidian/super_video
feat: 更新 Vite 配置以支持环境变量和基础路径
This commit is contained in:
1 parent
30f2d5e1f6
commit
66842e9d58
3 files changed
+27
-6
No files matched your search
@@ -0,0 +1,8 @@
|
||||
# 环境
|
||||
VITE_NODE_ENV=development
|
||||
|
||||
# 线上环境平台打包路径
|
||||
VITE_BASE_PATH=/super-video-h5
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# 环境
|
||||
VITE_NODE_ENV=production
|
||||
|
||||
# 线上环境平台打包路径
|
||||
VITE_BASE_PATH=/super-video-h5
|
||||
|
||||
+13
-6
@@ -1,13 +1,20 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { resolve } from 'path'
|
||||
|
||||
// 当前工作目录路径
|
||||
const root: string = process.cwd()
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src')
|
||||
export default defineConfig(({ mode }) => {
|
||||
// 环境变量
|
||||
const env = loadEnv(mode, root, '')
|
||||
return {
|
||||
plugins: [vue()],
|
||||
base: env.VITE_BASE_PATH || '/',
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user