-
Notifications
You must be signed in to change notification settings - Fork 59
Setting environment variable PUBLIC_URL does not set PUBLIC_URL on build #66
Comments
How do You send environment variable using rescripts? |
just create a |
I love the OS community –– thanks for covering this issue @webbushka 👍 |
Indeed! I believe this issue may be closed. 😄 |
has something changed to pick up that var? |
Yes, the var does get picked up. 👍 I believe this issue can be closed. Looking back at your first message, is it possible you had accidentally defined the URL to Here are steps to demonstrate proper behavior:
If you compare those last two commits, there will be no additional changes to the # create a third build after updating the PUBLIC_URL
echo "PUBLIC_URL=https://cssdb.org" > .env
nom run build
git add .
git commit -a -m "PUBLIC_URL is cssdb.org" Now, if you compare those last two commits, there will be several changes to the |
Wait. Wait. Wait. Once I add "env", it does break. 😢 Adding a babel configuration breaks it as well. Seeing if it is limited to certain plugins. It seems any plugin can break this functionality. I tried adding |
My bad, I updated the original comment. But yes I am using |
Adding any rescript plugin seems to remove the ability to define both the |
script on package.json -> "build": "node -r dotenv-flow/config 'node_modules/@rescripts/cli/bin/rescripts.js' build" have fun, thats my dirty hack on projects using rescripts... you need this https://www.npmjs.com/package/dotenv-flow |
Any updates on this? I'm currently working on a project that has a different |
@goransh good catch yeah you need to set the node-env since only inside the build script those are being hardcoded, dotenv is running before so the NODE_ENV it uses is the one set globally in your system. In my case it was okay because I was running the build inside a docker image, where I would set the NODE_ENV value through a build-arg in CI as an env value |
Description
When using the
PUBLIC_URL
field in.env
and then runningnpm run build
the build succeeds but thePUBLIC_URL
is not set. Seems that rescripts is ignoring the environmant variable. When settinghomepage
in package.jsonPUBLIC_URL
is set. This works in a base react-scripts app as well as with react-scripts-rewired. But when moving to rescripts it no longer works.@rescripts/[email protected]
@rescripts/[email protected]
[email protected]
Expected Behavior
URLs using the
PUBLIC_URL
variable should be set using thePUBLIC_URL
environment variable.Current Workaround
Add the url to your package.json as
'homepage'
The text was updated successfully, but these errors were encountered: