Using a custom .babelrc in create-react-app
See original GitHub issueDescribe the bug
I am using customize-cra
to add a specific babel plugin for development and I have also added a .babelrc
in the .storybook
folder which has the following:
{
"presets": ["react-app"],
"plugins": ["@babel/plugin-proposal-optional-chaining"]
}
The issue is it doesn’t read the babel config even though the terminal says:
But in the end it shows the following issue:
Expected behavior It should run the plugins and presets from the custom .babelrc file
System:
- OS: MacOS
- Device: Macbook
- Browser: Chrome
- Framework: React
- Version:
@storybook/react
: 5.0.6react-scripts
: 2.1.8
Issue Analytics
- State:
- Created 4 years ago
- Reactions:17
- Comments:28 (10 by maintainers)
Top Results From Across the Web
Simplest Way to Install Babel Plugins in Create React App
The traditional way of installing Babel plugins in a Create React App project requires you to eject the app via running npm run...
Read more >How to customize babel config? · Issue #167 - GitHub
In the project created by create-react-app , I want to add some code with ES Next decorators. So, I installed babel-plugin-transform-decorators- ...
Read more >Modify Create React App's Babel Configuration Without Ejecting
Learn how to modify the underlying Create React App configuration with customize-cra to include new babel plugins. All without having to ...
Read more >How to find .babelrc? - reactjs - Stack Overflow
If you have created React app using create-react-app, first you need to eject from the app so that you can use custom configuration....
Read more >Introducing new plugins in Babel to create react app
For using babel plugins without ejecting, you need to install react-app-rewired and customize-cra. ... Create a config-overrides.js file in the root directory: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
If you are using CRA and you need a custom config (like a babel plugin) you can use react-app-rewired with customize-cra.
Here’s how you can add the emotion css props plugin to both CRA + Storybook.
(This is useful for Emotion because the babel macro can’t setup the emotion css pragma, so really the babel plugin is required)
Step 1
Add customize CRA + React-app-rewired
Step 2: customize the CRA config:
Step 3: customize the Storybook config:
Note, you can keep using the CRA storybook preset
This way you don’t have to duplicate the config overrides, and can use the same overrides for both CRA and Storybook to keep them in sync.
Not yet @shilman, I’m checking now to see why the release is still held up.