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.

Including scripts from /public doesn't work

See original GitHub issue

I updated react-scripts to 0.5.1 and moved my index.html file to /public along with some javascript files from vendors. Now I have the following structure:

- node_module
  - ...
- public
  - vendor/abc.js
  - index.html
- src
  - App.js
  - index.js

Lets say abc.js does window.abc = 1, when the app loads, window.abc is undefined, so the script is not loading.

Here’s how I am including it in index.html:

    <script type="text/babel" src="vendor/abc.js"></script>

Note: I also tried using %PUBLIC_URL% with no luck. Though everything is under /public, so I am not sure if its needed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Jul 6, 2017

Please see the user guide: using global variables.

const Vibrant = window.Vibrant;

Then you can use it.

This way it’s clear you intentionally used a global variable rather than made a typo.

0reactions
yarnballcommented, Jul 7, 2017

Spot on. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not loading custom scripts from public folder Express ...
I want to load a custom script.js form the public folder but it doesnt seem to load. Nothing in the network tab, no...
Read more >
Why can't I include a js file?
I'm trying to include a js file, but for some reason I can't make it work. ... the JS file through a controller...
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
Basic Features: Handling Scripts
Offloading Scripts To A Web Worker (experimental) ... Note: The worker strategy is not yet stable and does not yet work with the...
Read more >
Serving Static Resources in Node.js
This will not break your application even if you run the express app from another ... must include myImage.png and public folder must...
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