¿Cómo establecer las variables de compilación .env cuando se ejecuta el script de compilación create-react-app?
Estoy usando la siguiente variable de entorno en mi aplicación create-react:
console.log(process.env.REACT_APP_API_URL) // http://localhost:5555
Funciona cuando corronpm start
leyendo un.env
archivo:
REACT_APP_API_URL=http://localhost:5555
¿Cómo configuro un valor diferente comohttp://localhost:1234
al ejecutar unnpm run build
?
Este es mipackage.json
archivo:
{
"name": "webapp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.0"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}