Skip to content

Git Repo information in package.json is added as PUBLIC_URL, causing broken build. #9547

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

Closed
swyxio opened this issue Aug 26, 2020 · 4 comments

Comments

@swyxio
Copy link
Contributor

swyxio commented Aug 26, 2020

Describe the bug

When I add git information to package.json, it somehow gets added to PUBLIC_URL, so that the built html has bad references like <link href="https://github.com/sw-yx/hi/static/css/main.5f361e03.chunk.css" rel="stylesheet" /> and <link rel="icon" href="https://github.com/sw-yx/h/favicon.ico" /> (which is even worse!!!).

i think this is a bug.

Did you try recovering your dependencies?

yarn 1.22.4

Which terms did you search for in User Guide?

PUBLIC_URL, prefix

Environment

Environment Info:

  current version of create-react-app: 3.4.1
  running from /Users/wanshawn/.npm/_npx/78798/lib/node_modules/create-react-app

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
  Binaries:
    Node: 12.18.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.7 - /usr/local/bin/npm
  Browsers:
    Chrome: 84.0.4147.135
    Firefox: 68.8.0
    Safari: 13.1.2
  npmPackages:
    react: ^16.13.1 => 16.13.1 
    react-dom: ^16.13.1 => 16.13.1 
    react-scripts: 3.4.3 => 3.4.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  • npm create react-app
  • gh create repo
  • npm init -y <- this adds repo details to package.json
  • yarn build

when you check build/index.html, you find the bug:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="/sw-yx/h/favicon.ico" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="/sw-yx/h/logo192.png" />
    <link rel="manifest" href="/sw-yx/h/manifest.json" />
    <title>React App</title>
    <link
      href="/sw-yx/hi/static/css/main.5f361e03.chunk.css"
      rel="stylesheet"
    />
  </head>

The bug is that /sw-yx/hi is inserted as PUBLIC_URL where it should not be, and even worse, in parts of it the last letter is snipped off.

Expected behavior

nothing in package.json should impact what PUBLIC_URL is

Actual behavior

Reproducible demo

https://github.com/sw-yx/hi

@agarun
Copy link

agarun commented Aug 27, 2020

I've also observed this behavior and it can be due to the homepage key being populated in package.json after init. The homepage key can be used instead of PUBLIC_URL and it's mentioned as an alternative

The broken link tags having /sw-yx/h/ are strange though, maybe due to the #readme bit

"homepage": "https://github.com/sw-yx/hi#readme"

@swyxio
Copy link
Contributor Author

swyxio commented Aug 27, 2020

that seems like it could be documented a lot better. and as you've mentioned its still buggy.

personally i'd prefer one way to do things.

@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Oct 4, 2020
@stale
Copy link

stale bot commented Oct 12, 2020

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants