A plugin to add the styled-components Babel plugin to create-react-app with react-app-rewired
npm install create-react-app-rewire-styled-componentscreate-react-app-rewire-styled-componentsThis is an updated version of original package react-app-rewire-styled-components created by Maximilian Stoiber, but no longer mantained.
Add the babel-plugin-styled-components to your create-react-app app via react-app-rewired.
This gives you nicer generated class names that include the components' name, minification of styles and many more goodies 💪
``sh`
npm install --save create-react-app-rewire-styled-componentsalternatively if you have yarn installed
yarn add create-react-app-rewire-styled-components
In the config-overrides.js you created for react-app-rewired add this code:
`JS
const rewireStyledComponents = require('create-react-app-rewire-styled-components');
/ config-overrides.js /
module.exports = function override(config, env) {
config = rewireStyledComponents(config, env);
return config;
}
`
That's it, you're now using the styled-components Babel plugin!
To pass options to the Babel plugin use the third argument, it passes straight through to the plugin:
`JS`
config = rewireStyledComponents(config, env, {
ssr: true,
})
See the available options in the styled-components` documentation.
Licensed under the MIT License, Copyright ©️ 2017 Maximilian Stoiber. See LICENSE.md for more information.
Relicensed under the MIT License, Copyright ©️ 2021 Paulo Griiettner.