mern-starter icon indicating copy to clipboard operation
mern-starter copied to clipboard

webpack load css files from node_modules

Open panvourtsis opened this issue 8 years ago • 4 comments

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?

panvourtsis avatar Dec 14 '16 08:12 panvourtsis

Same problem here

u0078867 avatar Jun 07 '17 11:06 u0078867

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');

zoeesilcock avatar Jul 18 '17 08:07 zoeesilcock

For bootstrap, I followed this and it worked like a charm:

https://medium.com/@vladbezden/webpack-configuration-for-using-bootstrap-in-react-a6ef2dfa1d95

u0078867 avatar Jul 18 '17 09:07 u0078867

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.

zoeesilcock avatar Jul 18 '17 19:07 zoeesilcock