Skip to content

Commit 8c89cf5

Browse files
committed
Flatten rules after oneOf was added to create-react-app webpack configs
see facebook/create-react-app#2747
1 parent 2157950 commit 8c89cf5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
function rewireGraphQLTag(config, env) {
33
const gqlExtension = /\.(graphql|gql)$/
44

5-
const fileLoader = config.module.rules.find(rule=> rule.loader && rule.loader.indexOf("file-loader")!==-1);
6-
fileLoader.exclude.push(gqlExtension);
5+
const flatten = (array) => array.reduce((a, b) =>
6+
a.concat(Array.isArray(b) ? flatten(b) : b), []);
7+
8+
const fileLoader = flatten(config.module.rules.map((rule) => rule.oneOf || rule))
9+
.find((rule) => rule.loader && rule.loader.indexOf("file-loader")!==-1);
10+
11+
fileLoader && fileLoader.exclude.push(gqlExtension);
712

813
const gqlTagRule = {
914
test: gqlExtension,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-app-rewire-graphql-tag",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "rewire your react-app and use graphql-tag",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)