I'm working on a web application which currently uses bootstrap for its front end, and webpack to bundle its assets. I've been inspired by this article to create web components which can be broken into tiny little self contained units, and this article to attempt to make my use of bootstrap more semantic.
The problem arises when I attempt to combine the two practices, by trying to make multiple web components, each of which extends the functionality of bootstrap. By attempting to import bootstrap into these independent components, bootstrap's style sheets end up getting duplicated several times in the final css bundle generated by webpack.
I've specifically been using bootstrap-sass so that I have access to bootstrap's individual components and variables. This way, I only have to import the functionality I need for each component. But this still doesn't solve the problem of duplicating the code, but only reduces it.
Ideally, webpack could be configured in a way such that all of these web components are extending the same copy of bootstrap, but I can't figure out how to do it.
Here is a gist I've created which demonstrates the problem. Upon running the code it generates app.css
which contains bootstrap's final css duplicated twice.
How can I structure my project so that I can semantically extend bootstrap, but still separate my style sheets into independent web components?