question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relative path for requesting static assets in dev mode

See original GitHub issue

When I do a prod build, static assets are requested from a relative path like ./static/js/bundle.js. When I do a dev build. static assets are requested from absolute path like /static/js/bundle.js. NOTE: I have an entry of "homepage": "." in my package.json

I want relative paths in my dev mode also. Any leads?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:5

github_iconTop GitHub Comments

3reactions
RoystonScommented, Jul 21, 2021

Issue seems to be here: https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/getPublicUrlOrPath.js#L55 The comment in the code says that . is supported to enable relative paths, but in development mode it explicitly ignores the path and uses /. 😦 The CRA documentation also explicitly suggests this configuration. (https://create-react-app.dev/docs/deployment/#serving-the-same-build-from-different-paths)

0reactions
raquelhortabcommented, Nov 2, 2022

How’s this still unsolved?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building does not set relative paths to the assets in `static` folder
Ensure that your static resources do not reside within directories "public/js" or "public/css". I chose "public/font" for the fonts in the case per...
Read more >
HTML and Static Assets - Vue CLI
Placed in the public directory and referenced via absolute paths. These assets will simply be copied and not go through webpack. Relative Path...
Read more >
Can I use relative path with webpack dev server - react js
so my production builds have a relative path, but the dev builds don't. Is there a way to have relative paths rather than...
Read more >
How to manage static files (e.g. images, JavaScript, CSS)
Configuring static files​​ In your templates, use the static template tag to build the URL for the given relative path using the configured...
Read more >
Static Asset Handling - Vite
Importing a static asset will return the resolved public URL when it is served: ... public paths (based on project root during dev)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found