Including scripts from /public doesn't work
See original GitHub issueI 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:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top 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 >
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
Please see the user guide: using global variables.
Then you can use it.
This way it’s clear you intentionally used a global variable rather than made a typo.
Spot on. Thank you