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.

Access PUBLIC_URL in js files

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Timercommented, Aug 28, 2017

process.env.PUBLIC_URL 😄

1reaction
Timercommented, Aug 28, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

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