-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Description
Description
Following the docs here (Building for Relative Paths), so setting homepage
field in package.json
doesn't set PUBLIC_URL during the build.
Expected behavior
%PUBLIC_URL%
in build/index.html
should be replaced with URL set in package.json's homepage
field.
package.json:
{
...
"homepage": "https://example.com",
...
}
build/index.html:
...
<script type="text/javascript" src="https://example.com/static/js/main.ec7f8972.js">
...
Actual behavior
%PUBLIC_URL%
will be replaced with nothing.
package.json:
{
...
"homepage": "https://example.com",
...
}
build/index.html:
...
<script type="text/javascript" src="/static/js/main.ec7f8972.js">
...
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected): 1.0.7node -v
: 8.1.2npm -v
: 5.0.3
Then, specify:
- Operating system: macOS 10.12.5
- Browser and version: Not relevant
Reproducible Demo
create-react-app my-app
(I used create-react-app 1.3.1)cd my-app
- Add
"homepage": "https://example.com"
to package.json yarn build
build/index.html
doesn't prepend URL to the paths in the script tag
But setting PUBLIC_URL=https://example.com
in .env
and build will produce the expected behaviour (adds URL to the script tag). Setting homepage
in package.json should do the same.
pkill37, tim-phillips, gpiress, jdupont, jsnbuchanan and 5 more