Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically fill in "homepage" in package.json with environment varaiables #998

Closed
ghost opened this issue Nov 1, 2016 · 2 comments
Closed

Comments

@ghost
Copy link

ghost commented Nov 1, 2016

Hi everyone,
I have this use case where I need to deploy my react app to both root url and a subdirectory.
I use subdirectories to deploy demo instances of the app.

For example:

http://dev.box/                          <-- this is for master branch
http://dev.box/branch-demo/branch-1      <-- CI systems will build and deploy branches to subdirectories
http://dev.box/branch-demo/branch-2

From previous discussions [1], I can use "homepage" field to adjust css and js paths in generated index.html. But for my use case, I'll need to change the "homepage" base on which location I'm deploying to.

I imagine solutions like:

HOMEPAGE='branch-demo/branch-1' npm run build

or like this in package.json (if possible):

{
  "homepage": "${HOMEPAGE}"
}

Any suggestions on how I can achieve dynamic values for homepage base on env variables?
Thanks!

@EnoahNetzach
Copy link
Contributor

Once #937 (or similar) will land it would be possible via the PUBLIC_URL environment variable.

@gaearon
Copy link
Contributor

gaearon commented Nov 20, 2016

Closing in favor of #937, let's track that instead.

@gaearon gaearon closed this as completed Nov 20, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants