We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
為了使根目錄乾淨,.env 可以放進 env 的資料夾
.env
如圖的 .env 分為三個,.env 是全部環境共用的 env 檔案,.env.development 是測試機專用的,.env.production 則是正式機, 但其實還可以多個 .env.staging ,是 for 上測試後但還未發正式機的情況,他可能是 beta- 之類的,也會跟正式和測試有區別。
.env.development
.env.production
.env.staging
beta-
只在本地有效的變量 .env.local
.env.local
有時候你可能有一些不應該提交到程式碼倉庫中的變數。 這種情況下你應該使用一個 .env.local 檔案取而代之。本地環境檔案預設會被忽略,且出現在 .gitignore 中。 .local 也可以加在指定模式的環境檔案上,比如 .env.development.local 將會在 development 模式下被載入,且被 git 忽略。
nuxt3 - 1
// nuxt.config.ts import { resolve } from "path"; const pathResolve = (dir: string) => { return resolve(__dirname, dir); } export default defineNuxtConfig({ vite: { envDir: pathResolve('./env'), }, });
nuxt3 - 2
// .env COOKIE_NAME=__session COOKIE_SECRET=superdupersecret
// nuxt.config.ts export default defineNuxtConfig({ runtimeConfig: { cookieName: process.env.COOKIE_NAME || "__session", cookieSecret: process.env.COOKIE_SECRET || "secret", }, });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
為了使根目錄乾淨,
.env
可以放進 env 的資料夾如圖的
.env
分為三個,.env
是全部環境共用的 env 檔案,.env.development
是測試機專用的,.env.production
則是正式機,但其實還可以多個
.env.staging
,是 for 上測試後但還未發正式機的情況,他可能是beta-
之類的,也會跟正式和測試有區別。只在本地有效的變量
.env.local
有時候你可能有一些不應該提交到程式碼倉庫中的變數。
這種情況下你應該使用一個 .env.local 檔案取而代之。本地環境檔案預設會被忽略,且出現在 .gitignore 中。
.local 也可以加在指定模式的環境檔案上,比如 .env.development.local 將會在 development 模式下被載入,且被 git 忽略。
nuxt3 - 1
nuxt3 - 2
The text was updated successfully, but these errors were encountered: