Oleksiï Nikonov
Oleksiï Nikonov

Reputation: 5598

How to change webpack config without Eject to set CSS as Module

Is there any way to keep generic webpack.config.dev.js without eject but override some features in it?

So i need a way to add some lines to get css modules

import styles from './styles.css';
...
<div className={styles.A}

I would like to avoid the command eject because i dont want to lose updates from react-team and like when project file structure is clear.

My webpack 4.19.1 generated by create-react-app

One more question: may be is there any third-party library helps to achieve such modular css files?

Upvotes: 0

Views: 642

Answers (1)

Khodor
Khodor

Reputation: 1006

This works by default in CRA 2.0+, though you should rename your css file to be styles.module.css

More info here

Upvotes: 3

Related Questions