Reccomended way to require CSS in webpack?
See original GitHub issueWhat is the recommended way to bring in the CSS from this packaged in webpack?
Just doing require('react-select')
appears to only bring in the javascript. I was able to get it working by adding require('react-select/less/default.less')
or require('react-select/dist/default.css')
to my javascript file.
I’m new to node packages so I’m not clear if that is by design or not.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:46
- Comments:35 (1 by maintainers)
Top Results From Across the Web
css-loader | webpack - JS.ORG
The css-loader interprets @import and url() like import/require() and will ... store CSS in a JS module) you might want to check out...
Read more >How to configure CSS Modules for webpack - LogRocket Blog
In this article, we will practice using CSS Modules with a webpack demo project in order to learn how to configure an app...
Read more >How to import CSS files into webpack? - Stack Overflow
To import webpack/static/css/myfile.css in webpack/entry.js you have to use a relative path. import './static/css/myfile.css';.
Read more >How to CSS with Webpack 5 - Setup Tutorial
Learn how to use CSS in a Webpack powered JavaScript application . ... First of all, you need to install a CSS loader...
Read more >Bundling CSS with webpack Loaders
A loader preprocesses a file before it's actually loaded by webpack. We need these loaders because webpack only understands JavaScript, not ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should really be included in the documentation.
Not sure if it helps someone, but I used a small wrapper component for react-select which imports the dependencies. The
.jsx
file wraps the default<Select />
component in a wrapper class which can be created by css modules.The
.scss
file first runs through thesass-loader
and thencss-loader
(with modules). This allows sass variable configuration and helps namespace the default styles to avoid impacting anything else.