Relative path for requesting static assets in dev mode
See original GitHub issueWhen 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:
- Created 2 years ago
- Reactions:7
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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)How’s this still unsolved?