React-select: Using react-select with webpack instead of browsify

Created on 16 Oct 2015  路  10Comments  路  Source: JedWatson/react-select

Hi,
i am using webpack for bundling in my application. I tried importing the react-select only the JS is getting bundled and the CSS is not. Is there a example which i can refer how to use this with webpack

Thanks
Om

Most helpful comment

Hi,

Include the css loader in your webpack, for example:

module.exports = {
  module: {
    loaders: [
      { test: /\.css$/, loader: "style!css" },
    ]
  }
};

And in your react component you can require the css file from react-select module:

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

All 10 comments

Hi,

Include the css loader in your webpack, for example:

module.exports = {
  module: {
    loaders: [
      { test: /\.css$/, loader: "style!css" },
    ]
  }
};

And in your react component you can require the css file from react-select module:

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

thanks, @maxcnunes. This should really be in the docs.

I'm using webpack and I'm importing the scss filed to be able to reset some select.scss vars

Can you provide any more details on this? I'm not too familiar with webpack and with the above code, it's telling me it can't find the default.css in /path/to/my/component.js

@dyyylan

require('react-select/dist/default.css'); isn't the correct path in the latest few versions. Check the path to the css.

Ok, I updated the path (currently react-select/dist/react-select.css). Now I am getting this error:
Module not found: Error: Cannot resolve module 'style' in /path/to/component.js

If I look at the page it says something about webpack-style-loader?

@dyyylan You should have installed css-loader and style-loader

npm install css-loader style-loader

But if you are not interested learning how to use webpack then is much easier running it without webpack.

Ok, thanks for the help.

@maxcnunes Google brought me here-- thanks for the clear explanation. Works great!

Thanks for explaining :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steida picture steida  路  3Comments

batusai513 picture batusai513  路  3Comments

Meesam picture Meesam  路  3Comments

geraldfullam picture geraldfullam  路  3Comments

coder-guy22296 picture coder-guy22296  路  3Comments