Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 16ed217

Browse files
author
Can Uzunoglu
committed
Update SC Rewire to make it work with CRA 1.0.11
1 parent 341c362 commit 16ed217

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
]
2424
},
2525
"dependencies": {
26-
"babel-plugin-styled-components": "^1.1.4"
26+
"babel-plugin-styled-components": "^1.1.4",
27+
"react-app-rewired": "^1.2.0"
2728
},
2829
"peerDependencies": {
2930
"styled-components": "2.x"

src/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
const { injectBabelPlugin } = require('react-app-rewired');
2+
13
function rewireStyledComponents(
24
config,
35
env,
46
styledComponentsPluginOptions = {}
57
) {
6-
const babelLoader = config.module.rules.find(
7-
rule => rule.loader && rule.loader.indexOf('babel-loader') > 0
8+
return injectBabelPlugin(
9+
['styled-components', styledComponentsPluginOptions],
10+
config
811
);
9-
babelLoader.options.plugins = (babelLoader.options.plugins || [])
10-
.concat([['styled-components', styledComponentsPluginOptions]]);
11-
12-
return config;
1312
}
1413

1514
module.exports = rewireStyledComponents;

yarn.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ cosmiconfig@^1.1.0:
924924
pinkie-promise "^2.0.0"
925925
require-from-string "^1.1.0"
926926

927-
cross-spawn@^5.0.1:
927+
cross-spawn@^5.0.1, cross-spawn@^5.1.0:
928928
version "5.1.0"
929929
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
930930
dependencies:
@@ -1000,6 +1000,10 @@ diff@^3.0.0:
10001000
version "3.2.0"
10011001
resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9"
10021002

1003+
dotenv@^4.0.0:
1004+
version "4.0.0"
1005+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
1006+
10031007
ecc-jsbn@~0.1.1:
10041008
version "0.1.1"
10051009
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
@@ -2420,6 +2424,13 @@ rc@^1.1.7:
24202424
minimist "^1.2.0"
24212425
strip-json-comments "~2.0.1"
24222426

2427+
react-app-rewired@^1.2.0:
2428+
version "1.2.0"
2429+
resolved "https://registry.yarnpkg.com/react-app-rewired/-/react-app-rewired-1.2.0.tgz#0ecab9007292ee5ed50812eb93818065d12da561"
2430+
dependencies:
2431+
cross-spawn "^5.1.0"
2432+
dotenv "^4.0.0"
2433+
24232434
read-pkg-up@^1.0.1:
24242435
version "1.0.1"
24252436
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02"

0 commit comments

Comments
 (0)