You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use single-quotes in test cases so Babel copies us
* Automatically allow hot-reloading of imported CSS
* Add webpackHotModuleReloading option
* Document webpack hot module reloading
* docs: add instructions for enabling live CSS reloading
Copy file name to clipboardExpand all lines: README.md
+22-2
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,7 @@ In contrast to [`react-css-modules`](https://github.com/gajus/react-css-modules)
31
31
*[Have a question or want to suggest an improvement?](#have-a-question-or-want-to-suggest-an-improvement)
32
32
*[FAQ](#faq)
33
33
*[How to reference multiple CSS modules?](#how-to-reference-multiple-css-modules)
34
+
*[How to live reload the CSS?](#hot-to-live-reload-the-css)
34
35
35
36
## CSS Modules
36
37
@@ -173,6 +174,7 @@ NODE_ENV=production ./test
173
174
|---|---|---|
174
175
|`context`|Must match webpack [`context`](https://webpack.github.io/docs/configuration.html#context) configuration. [`css-loader`](https://github.com/webpack/css-loader) inherits `context` values from webpack. Other CSS module implementations might use different context resolution logic.|`process.cwd()`|
175
176
|`filetypes`|Configure [postcss syntax loaders](https://github.com/postcss/postcss#syntaxes) like sugerss, LESS and SCSS. ||
177
+
|`webpackHotModuleReloading`|Enables hot reloading of CSS in webpack|`false`|
176
178
|`generateScopedName`|Refer to [Generating scoped names](https://github.com/css-modules/postcss-modules#generating-scoped-names)|`[path]___[name]__[local]___[hash:base64:5]`|
177
179
178
180
Missing a configuration? [Raise an issue](https://github.com/gajus/babel-plugin-react-css-modules/issues/new?title=New%20configuration:).
@@ -185,13 +187,13 @@ Missing a configuration? [Raise an issue](https://github.com/gajus/babel-plugin-
185
187
To add support for different CSS syntaxes (e.g. SCSS), perform the following two steps:
186
188
187
189
1. Add the [postcss syntax loader](https://github.com/postcss/postcss#syntaxes) as a development dependency:
188
-
190
+
189
191
```bash
190
192
npm install postcss-scss --save-dev
191
193
```
192
194
193
195
2. Add a filetype syntax mapping to the Babel plugin configuration
This behaviour is enabled by default in `babel-plugin-react-css-modules`.
363
+
364
+
## How to live reload the CSS?
365
+
366
+
`babel-plugin-react-css-modules` utilises webpack [Hot Module Replacement](https://webpack.github.io/docs/hot-module-replacement.html) (HMR) to live reload the CSS.
* Configure `webpack` to use HMR. Use [`--hot`](https://webpack.github.io/docs/webpack-dev-server.html) option if you are using `webpack-dev-server`.
372
+
* Use [`style-loader`](https://github.com/webpack/style-loader) to load the style sheets.
373
+
374
+
> Note:
375
+
>
376
+
> This enables live reloading of the CSS. To enable HMR of the React components, refer to the [Hot Module Replacement - React](https://webpack.js.org/guides/hmr-react/) guide.
377
+
378
+
> Note:
379
+
>
380
+
> This is a [webpack](https://webpack.github.io/) specific option. If you are using `babel-plugin-react-css-modules` in a different setup and require CSS live reloading, raise an issue describing your setup.
0 commit comments