Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b3ae56b

Browse files
sthzggajus
authored andcommitted
feat: respect exclude setting in JSXElement transform (#215)
BREAKING CHANGE: * exclude logic is used to exclude JSXElement containing files
1 parent 4fa15f5 commit b3ae56b

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

‎demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"start": "webpack-dev-server"
55
},
66
"dependencies": {
7-
"babel-plugin-react-css-modules": "^2.1.3",
7+
"babel-plugin-react-css-modules": "^4.0.0",
88
"react": "^15.4.1",
99
"react-dom": "^15.4.1",
1010
"webpack": "^2.7.0"

‎src/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ export default ({
121121
return require.resolve(path.node.source.value);
122122
};
123123

124+
const isFilenameExcluded = (filename, exclude) => {
125+
return filename.match(new RegExp(exclude));
126+
};
127+
124128
const notForPlugin = (path: *, stats: *) => {
125129
stats.opts.filetypes = stats.opts.filetypes || {};
126130

@@ -130,7 +134,9 @@ export default ({
130134
return true;
131135
}
132136

133-
if (stats.opts.exclude && getTargetResourcePath(path, stats).match(new RegExp(stats.opts.exclude))) {
137+
const filename = getTargetResourcePath(path, stats);
138+
139+
if (stats.opts.exclude && isFilenameExcluded(filename, stats.opts.exclude)) {
134140
return true;
135141
}
136142

@@ -179,6 +185,10 @@ export default ({
179185
JSXElement (path: *, stats: *): void {
180186
const filename = stats.file.opts.filename;
181187

188+
if (stats.opts.exclude && isFilenameExcluded(filename, stats.opts.exclude)) {
189+
return;
190+
}
191+
182192
let attributeNames = optionsDefaults.attributeNames;
183193

184194
if (stats.opts && stats.opts.attributeNames) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div styleName="missing_import" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": [
3+
[
4+
"../../../../src",
5+
{
6+
"generateScopedName": "[name]__[local]",
7+
"exclude": "input"
8+
}
9+
]
10+
]
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
<div styleName="missing_import" />;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /