vintem vintem - 17 days ago 6
React JSX Question

Using webpack to load CSS files from node modules

I'm trying to use a react component that includes a css file. I'm requiring the component as usual:

var Select = require('react-select');


I'd like to know how can I require the css needed for the component.

I've already tried this:

require('react-select/dist/react-select.css');


And this:

require('react-select.css');


And none have worked.

Answer
//package.json
"dependencies": {
    "my-package": "2.0.0"
}
//app.js
//Get a relative path to the installed css files:
require('../someRelativePathFromAppJs/node_modules/my-package/somePath/myNeeded.css')