Skip to content

Commit fe1b3a5

Browse files
committed
feat: add removeImport configuration
1 parent b7f6ca8 commit fe1b3a5

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ NODE_ENV=production ./test
173173
|Name|Description|Default|
174174
|---|---|---|
175175
|`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()`|
176+
|`exclude`| a RegExp that will exclude otherwise included files e.g., to exclude all styles from node_modules `exclude: 'node_modules'`|
176177
|`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`|
178178
|`generateScopedName`|Refer to [Generating scoped names](https://github.com/css-modules/postcss-modules#generating-scoped-names)|`[path]___[name]__[local]___[hash:base64:5]`|
179-
|`exclude`| a RegExp that will exclude otherwise included files e.g., to exclude all styles from node_modules `exclude: 'node_modules'`|
179+
|`removeImport`|Remove the matching style import. This option is used to enable server-side rendering.|`false`|
180+
|`webpackHotModuleReloading`|Enables hot reloading of CSS in webpack|`false`|
180181

181182
Missing a configuration? [Raise an issue](https://github.com/gajus/babel-plugin-react-css-modules/issues/new?title=New%20configuration:).
182183

@@ -377,5 +378,5 @@ To enable live reloading of the CSS:
377378
> 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.
378379
379380
> Note:
380-
>
381+
>
381382
> 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.

src/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ export default ({
164164
if (stats.opts.webpackHotModuleReloading) {
165165
addWebpackHotModuleAccept(path);
166166
}
167+
168+
if (stats.opts.removeImport) {
169+
path.remove();
170+
}
167171
},
168172
JSXElement (path: Object, stats: Object): void {
169173
const filename = stats.file.opts.filename;

src/schemas/optionsSchema.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@
44
"context": {
55
"type": "string"
66
},
7+
"exclude": {
8+
"type": "string"
9+
},
710
"filetypes": {
11+
"additionalProperties": false,
812
"patternProperties": {
913
"\\..*": {
1014
"type": "string"
1115
}
1216
},
13-
"additionalProperties": false,
1417
"type": "object"
1518
},
1619
"generateScopedName": {
1720
"type": "string"
1821
},
19-
"webpackHotModuleReloading": {
22+
"removeImport": {
2023
"type": "boolean"
2124
},
22-
"exclude": {
23-
"type": "string"
25+
"webpackHotModuleReloading": {
26+
"type": "boolean"
2427
}
2528
},
2629
"type": "object"

0 commit comments

Comments
 (0)