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

Commit fae9e35

Browse files
committed
Update SC rewire to make it work with CRA 1.0.0
1 parent 6512c71 commit fae9e35

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
const babelLoader = function(conf) {
2-
return conf.loader === 'babel';
3-
};
4-
5-
function rewireStyledComponents(config) {
6-
const babelrc = config.module.loaders.find(babelLoader).query;
7-
babelrc.plugins = ['styled-components'].concat(babelrc.plugins || []);
1+
function rewireStyledComponents(
2+
config,
3+
env,
4+
styledComponentsPluginOptions = {}
5+
) {
6+
const babelLoader = config.module.rules.find(
7+
rule => rule.loader && rule.loader.indexOf('babel-loader') > 0
8+
);
9+
babelLoader.options.plugins = (babelLoader.options.plugins || [])
10+
.concat([['styled-components', styledComponentsPluginOptions]]);
811

912
return config;
1013
}
1114

12-
export default rewireStyledComponents;
15+
module.exports = rewireStyledComponents;

0 commit comments

Comments
 (0)