[英]React - Env variables in development AND production
我敢肯定這已經被回答過了,但是它對您鏈接的內容說的很對。 在項目的根目錄(與package.json,.gitignore等級別)中創建2個文件,.env.development和.env.production。 根據下面列出的層次結構,無論運行哪種腳本,都將確定使用哪種腳本。
.env: Default.
.env.local: Local overrides. This file is loaded for all environments except test.
.env.development, .env.test, .env.production: Environment-specific settings.
.env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings.
Files on the left have more priority than files on the right:
npm start: .env.development.local, .env.development, .env.local, .env
npm run build: .env.production.local, .env.production, .env.local, .env
npm test: .env.test.local, .env.test, .env (note .env.local is missing)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.