I have a specific question below, but I think the more general question is, how can I control what webpack adds to my build automatically (especially without depending on external modules)?
I have a simple 10-line js example I’m trying to use with webpack. When I run locally with webpack-dev-server, I see that
bundle.js is >300KB. I assume this is because
node_modules is being included, correct?
The file size of dist/bundle.js is ~2KB, so this is apparently being done at runtime.
I’ve added babel-loader and the necessary rules as specified on the package’s repo README to my webpack config. I don’t receive any errors when running locally, so I assume that the configuration is now correct.
However, my bundle.js is still showing 300KB+ in dev tools. How can I get rid of this stuff? This is simply a short example with plain JS inserting a single DOM element, so I (obviously) don’t need all the extra stuff.
None of the existing SO posts or blog articles I’ve been able to locate have been helpful (they all use some variation of
exclude, and I’ve tried them all, and have seen config errors in cases where they weren’t specified correctly, so that’s why I believe it’s specified correctly now).
(Posting here because webpack questions are no longer answered on SO, which leaves no other resources AFAIK.)