DEV Community

Discussion on: How to import CSS in React.js component?

Collapse
 
maksimmedvedev profile image
MaksimMedvedev • Edited

A misleading title with no useful information at all (IMHO).
Surely it's gonna work for smth like create-react-app (because , but it does not answer the question of how to actually import .css (and basically any file other than JS modules) in react (and basically in any JavaScript file)

For anyone who accidentally spots this article and is interested in it just google webpack, webpack loaders or any other loaders in any other bundlers (parcel, esbuild, rollup)

FYI, inside a JS file you cannot import anything other that another JS-module so you need something that searches for code that imports .css, then transforms that .css module into a JS module and replaces the .css import with an ordinary JS import
(correct me if I'm wrong, interesting to know other ways to do it)

Collapse
 
duomly profile image
Duomly

Hi, thanks for the input,
but the title is 100% fine (it tells "How to import CSS in React.js component", and I show exactly that).

Webpack configuration and loaders are a topic that we'll cover in another episode, and the title would be misleading if I'd show how to config webpack loaders in the current episode :)

Still, some people would like to know how to just import CSS files into the react component, so in this episode, we wanted to show how to do it in the simplest way.