Replies: 1 comment 5 replies
-
what you mean by scripts? You want to do something like: <html>
<script src="my-3-builded-scripts.js"></script>
<script src="app.js"></script><!-- consume functions here -->
</html> If so you need to output a library ( e.g. in example above you can use umd library https://webpack.js.org/guides/author-libraries/#expose-the-library ) Also you can use them in one entrypoint like:
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been pulling my hair out for a while on this and I cannot seem to find the right keywords to use on Google to help me figure this out myself so, I'm turning to the collective minds of the webpack community on Github.
Anyways, I have three scripts. Script A has a
window.addEventHandler("DOMContentLoaded")
in it to do some stuff when the page has loaded (set up some events specific to the page, etc) and an exported function. Scripts B and C just export a function each.Now, I can include each script on the page seperately and then I can call the exported functions from the HTML fine. But, I feel like this is the "wrong" way of doing this? I would expect that I would be able to add the scripts to a single entry point and use the exports that way but, it seems like only the last script's exported functions get added to the window. I've tried to mark the scripts with only function exports as "sideEffect" but, I still wasn't able to use the functions in HTML.
So is it better to define each script individually or, is there a way to group them together whilst still being able to use the functions from HTML?
Example of my use case:
I currently have something like this in my config
Beta Was this translation helpful? Give feedback.
All reactions