.env.developmentREACT_APP_AUTHORIZATION_TOKEN="" REACT_APP_LAMBDA_URL=""
.env.development
.env.staging
.env.production
というenvファイルがある。yarn dev時には、env.development
が適用され、build時には.env.production
が問答無用で適用されていた。
下記のような npm scriptを書くと、解決できた。
"scripts": { "build": "sh -ac '. ./.env.${REACT_APP_ENV}; react-scripts build'", "build:dev": "yarn tsc && yarn test && REACT_APP_ENV=development yarn build", "build:staging": "yarn tsc && yarn test && REACT_APP_ENV=staging yarn build", "build:prod": "yarn tsc && yarn test && REACT_APP_ENV=production yarn build", },