mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-28 03:01:28 +08:00
fix(docker): 优化 Vite 配置以支持 Docker 构建环境
- 修改 vite.config.ts 在 Docker 环境中使用当前目录加载 .env 文件 - 在 Dockerfile 中设置 DOCKER_BUILD 环境变量 - 移除不必要的 .env.example 复制步骤 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd() + '/../')
|
||||
// 在 Docker 环境中,父目录可能没有 .env 文件,使用当前目录
|
||||
const envDir = process.env.DOCKER_BUILD ? __dirname : path.resolve(__dirname, '../')
|
||||
const env = loadEnv(mode, envDir)
|
||||
|
||||
const apiBaseUrl = env.VITE_API_BASE_URL || 'http://127.0.0.1:8483'
|
||||
const port = parseInt(env.VITE_FRONTEND_PORT || '3015', 10)
|
||||
|
||||
Reference in New Issue
Block a user