Sunday, 16 June 2019

The best way include a script fetched using the script tag in your webpack bundle?

I have a node application that has a dependency of a minified script, which I get from a CDN using the script tag. Now I want to bundle all my application's javascript file together using webpack into a single js file, but I want to include the CDN minified script as well, so the user of my application don't have to include that minified script in their application. What is the best way to achieve this? Two simple ways I can think of are:Copy and paste that minified script into a file, and import that file somewhere in my code.At the entry point of my application, I make an ajax call to fetch the minified script instead of getting it using script tag.Is there any better way? Can I make that minified script somehow to be a part of my npm dependencies?

Submitted June 17, 2019 at 12:36AM by lexaxy

No comments:

Post a Comment