fix: 環境變數讀取
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
# vite / vite dev:預設 mode = development
|
||||
# vite build:預設 mode = production
|
||||
# vite --mode staging:改成 staging
|
||||
# vite build --mode development:build 但用 development mode
|
||||
|
||||
# 覆蓋優先從低至高
|
||||
# .env
|
||||
# .env.local
|
||||
# .env.[mode]
|
||||
# .env.[mode].local
|
||||
|
||||
|
||||
|
||||
# Vite dev proxy 目標後端 URL。
|
||||
VITE_PROXY_TARGET=http://192.168.89.54:9002
|
||||
|
||||
|
||||
+7
-4
@@ -1,10 +1,13 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import Vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import Vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
Vue({
|
||||
template: { transformAssetUrls },
|
||||
@@ -36,7 +39,7 @@ export default defineConfig({
|
||||
port: 3700,
|
||||
proxy:{
|
||||
"/service/": {
|
||||
target: process.env.VITE_PROXY_TARGET || "http://localhost:8080",
|
||||
target: env.VITE_PROXY_TARGET || "http://localhost:8080",
|
||||
changeOrigin: true,
|
||||
},
|
||||
}
|
||||
@@ -47,4 +50,4 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user