Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/withspectrum/react-app-rewire-styled-components

Add the styled-components Babel plugin to your create-react-app app via react-app-rewired
https://github.com/withspectrum/react-app-rewire-styled-components

create-react-app create-react-app-styled-components react-app-rewire styled-components

Last synced: about 2 months ago
JSON representation

Add the styled-components Babel plugin to your create-react-app app via react-app-rewired

Awesome Lists containing this project

README

        

# `react-app-rewire-styled-components`

Add the [`babel-plugin-styled-components`](https://github.com/styled-components/babel-plugin-styled-components) to your `create-react-app` app via [`react-app-rewired`](https://github.com/timarney/react-app-rewired).

This gives you nicer generated class names that include the components' name, minification of styles and many more goodies đŸ’Ē

## Installation

```sh
npm install --save react-app-rewire-styled-components
# alternatively if you have yarn installed
yarn add react-app-rewire-styled-components
```

## Usage

In the `config-overrides.js` you created for `react-app-rewired` add this code:

```JS
const rewireStyledComponents = require('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](https://www.styled-components.com/docs/tooling#babel-plugin) in the `styled-components` documentation.

## License

Licensed under the MIT License, Copyright Šī¸ 2017 Maximilian Stoiber. See [LICENSE.md](LICENSE.md) for more information.