4.0.0 • Published 7 years ago
react-app-rewire-emotion v4.0.0
react-app-rewire-emotion
Add emotion/babel babel plugin to create-react-app using react-app-rewired
Add the emotion/babel to create-react-app app via react-app-rewired
Installation
yarn add --dev react-app-rewire-emotionOR
npm install --save-dev react-app-rewire-emotionUsage
In the config-overrides.js you created for react-app-rewired add this code:
const { rewireEmotion } = require('react-app-rewire-emotion');
/* config-overrides.js */
module.exports = function override(config, env) {
return rewireEmotion(config, env, { inline: true });
}If you are using compose utility provided by react-app-rewired to add multiple rewires, use this code:
const { compose } = require('react-app-rewired');
const { createEmotionRewire } = require('react-app-rewire-emotion');
/* config-overrides.js */
module.exports = function override(config, env) {
const rewires = compose(
createRewireForSomeOtherPlugin(),
// ... place more rewires
createEmotionRewire({ inline: true }),
);
return rewires(config, env);
};Usage with Storybook
When using @storybooks/storybook with CRA via getstorybook, create a webpack.config.js file in .storybook folder and add this code:
const rewireEmotion = require('react-app-rewire-emotion');
module.exports = function override(config, env) {
return rewireEmotion(config, env, { inline: true });
};Inspirations
react-app-rewire-styled-components by @mxstbr
License
Licensed under MIT License, Copyright @ 2017 osdevisnot. See LICENSE.md for more details.