공부
[reactjs] npm install --save-dev env-cmd; ./node_modules/.bin/env-cmd -f ./stage.env npm build
승가비
2023. 8. 20. 12:38
728x90
"scripts": {
"start": "react-scripts start",
"start:stg": "env-cmd -f .env react-scripts start",
"start:prd": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint 'src/**/*.{js,ts,tsx}'"
},
How to set build .env variables when running create-react-app build script?
I'm using the following environment variable in my create-react-app: console.log(process.env.REACT_APP_API_URL) // http://localhost:5555 It works when I run npm start by reading a .env file:
stackoverflow.com
npm install --save-dev env-cmd
./node_modules/.bin/env-cmd -f ./stage.env npm build
728x90