Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include relative static files from index.html #3079

Open
ValerieMichaud opened this issue Jan 5, 2023 · 3 comments
Open

Include relative static files from index.html #3079

ValerieMichaud opened this issue Jan 5, 2023 · 3 comments

Comments

@ValerieMichaud
Copy link

I'm not super familiar with webpack and I'm trying to include some JS files in index.html
For example:
index.html
[ lib ]
- file1.js
- file2.js

I'm looking to achieve something like that:
<script src='lib/file1.js'></script>

I've looked at #984 but that didnt' help my solve my issue, as it's a very old post.

@govind15496
Copy link

This will include the - file1.js script in your HTML file.
If you want to include multiple scripts, you can add multiple script elements:

<script src='lib/file1.js'></script> <script src='lib/file2.js'></script>

@ValerieMichaud
Copy link
Author

Sorry but how do I get the "lib" folder to be served as a static folder in webpack?
If I do like in your example, I get a 404 error because the router is trying to render
Localhost:3000/lib/file1.js
Which doesn't exist because the lib folder isn't served properly

@govind15496
Copy link

You can use the CopyWebpackPlugin to copy the lib folder to the output directory during the build process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants