Skip to content

Commit

Permalink
Flatten rules after oneOf was added to create-react-app webpack configs
Browse files Browse the repository at this point in the history
  • Loading branch information
tb committed Oct 15, 2017
1 parent 2157950 commit 1ed239f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
function rewireGraphQLTag(config, env) {
const gqlExtension = /\.(graphql|gql)$/

const fileLoader = config.module.rules.find(rule=> rule.loader && rule.loader.indexOf("file-loader")!==-1);
fileLoader.exclude.push(gqlExtension);
const fileLoader = flatten(config.module.rules.map((rule) => rule.oneOf || rule))
.find((rule) => rule.loader && rule.loader.indexOf("file-loader")!==-1);

fileLoader && fileLoader.exclude.push(gqlExtension);

const gqlTagRule = {
test: gqlExtension,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-app-rewire-graphql-tag",
"version": "1.0.0",
"version": "1.1.0",
"description": "rewire your react-app and use graphql-tag",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 1ed239f

Please sign in to comment.