mern-starter
mern-starter copied to clipboard
webpack load css files from node_modules
In our webpack config there is the line that if we load css from modules can add it to the bundle #157 but how about if we require a module that uses css? Then we are getting errors.
Have anyone has the same problem as me?
Same problem here
I was also having problems importing .css files from node_modules. What worked for me was using require
instead of import
or @import
.
Example from my client/App.js:
require('../node_modules/bootstrap/dist/css/bootstrap.css');
require('../node_modules/bootstrap/dist/css/bootstrap-theme.css');
For bootstrap, I followed this and it worked like a charm:
https://medium.com/@vladbezden/webpack-configuration-for-using-bootstrap-in-react-a6ef2dfa1d95
Thanks @u0078867, that's even better than what I figured out. I'm back to using import with the paths mentioned in that article now.