在我的项目中,我有很多git分支名称(开发,测试,阶段....),我正在使用Docker构建我的React应用,并使用Jenkins进行部署。
What I want is to specify my REACT_APP_BASE_URL based on my current branch name because I have several base URLs, for example (https://abc.dev.example, https://abc.test.example ..), and I want to run the matched name.
我所做的是:
- create .env.dev : REACT_APP_BASE_URL= 'https://abc.dev.example'
- create .env.production : REACT_APP_BASE_URL= 'https://abc.production.example'
- create .env.test : REACT_APP_BASE_URL= 'https://abc.test.example'
- npm install env-cmd --save
我的剧本:
"start": "env-cmd -f .env.dev react-app-rewired start",
"build": "react-app-rewired build",
"build:develop": "env-cmd -f .env.dev react-app-rewired build",
"build:test": "env-cmd -f .env.test react-app-rewired build",
"build:demo": "env-cmd -f .env.demo react-app-rewired build",
It's always looking for the url on .env.production
file for all branches because it considers the production during the build process, so how can I solve that?
Any ideas?