Hi @rob
I think I’m missing something yet. I’ve tried doing it with a project I’ve created from scratch with the RedwoodJS version 6.6.2
but I failed to make it work with the .env.production
file. Let’s say I create a project with
yarn create redwood-app my_project
And in this project I write the following in my .env.defaults
file
REDWOOD_ENV_myvar="development value"
As well as a new .env.production
file:
REDWOOD_ENV_myvar="production value"
Finally, if I create a home
page for it
yarn rw generate page home /
And on this page, I write a console.log(process.env.REDWOOD_ENV_myvar)
to check the value of my environment variable… I’ve tried it in multiple ways like:
NODE_ENV=production yarn rw dev
and
export NODE_ENV=production
yarn rw dev
and
NODE_ENV=production yarn rw build
NODE_ENV=production yarn rw serve
and
export NODE_ENV=production
yarn rw build
yarn rw serve
All of them will make my frontend print the value of .env.defaults
and ignore my .env.production
. Am I missing anything in it?
Particularly while running it with yarn rw dev
, I’ve noticed that when I close the process that’s running in the terminal it shows some commands:
NODE_ENV=production yarn rw dev
web | ➜ Local: http://localhost:8910/
web | ➜ Network: http://10.20.0.184:8910/
web | ➜ Network: http://172.22.0.1:8910/
web | ➜ Network: http://172.19.0.1:8910/
web | ➜ Network: http://172.21.0.1:8910/
web | ➜ Network: http://192.168.176.1:8910/
web | ➜ Network: http://10.15.2.65:8910/
gen | Generating full TypeScript definitions and GraphQL schemas
gen | Done.
api | Building... Took 223 ms
api | Debugger listening on ws://127.0.0.1:18911/0e3c6964-4edb-4278-aa9d-e8874aa6fdb3
api | For help, see: https://nodejs.org/en/docs/inspector
api | Starting API Server...
api | Loading server config from /home/Dados/Projetos/testes/my_project/api/server.config.js
api |
api | Importing Server Functions...
api | /graphql 237 ms
api | ...Done importing in 237 ms
api | Took 262 ms
api | API listening on http://localhost:8911/
api | GraphQL endpoint at /graphql
api | 18:04:21 🌲 Server listening at http://[::]:8911
^Cgen | yarn rw-gen-watch exited with code SIGINT
web | yarn cross-env NODE_ENV=development rw-vite-dev exited with code SIGINT
api | yarn cross-env NODE_ENV=development NODE_OPTIONS="--enable-source-maps" yarn nodemon --quiet --watch "/home/Dados/Projetos/testes/my_project/redwood.toml" --exec "yarn rw-api-server-watch --port 8911 --debug-port 18911 | rw-log-formatter" exited with code SIGINT
The last two lines have NODE_ENV=development
, it’s like it’s enforcing the value of NODE_ENV to be development
…