Access PUBLIC_URL in js files
See original GitHub issueI need to have some widget.js
in public
folder. This file will create iframe and init my React app into this iframe. To do this manipulation I need access to a %PUBLIC_URL%
property but looks like it works only for .html
files. There is some way to solve this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Using the Public Folder
The public folder contains the HTML file so you can tweak it, for example, ... encourage you to import assets in JavaScript files...
Read more >Reference file in public folder from CSS in create-react-app
The proposed solution is to add the style inside the JavaScript file which I don't want to do. node.js · reactjs · create-react-app...
Read more >Configure the create-react-app public URL post-build with ...
Configure the create-react-app public URL post-build with Node.js and ... E.g. the URL to your favicon in the build output index.html file ......
Read more >Basic Features: Static File Serving
js can serve static files, like images, under a folder called public in the root directory. Files inside public can then be referenced...
Read more >Static Asset Handling
Importing a static asset will return the resolved public URL when it is served: js ... The behavior is similar to webpack's file-loader...
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 FreeTop 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
Top GitHub Comments
process.env.PUBLIC_URL
😄Oops, my mistake! There’s currently no way to use this in other files. For now, I’d suggest a custom script which performs this interpolation for you.