Storybook stops working on Create-react-app (CRA) after ejecting
See original GitHub issueDescribe the bug
Storybook stops working, after ejecting CRA. Gives Module parse failed: Unexpected token
error.
To Reproduce Steps to reproduce the behavior:
- Install CRA
npx create-react-app storybook-typescript-eject --typescript
andcd storybook-typescript-eject
. - Install Storybook
npx -p @storybook/cli sb init
- Verity it works
npm run storybook
- Eject
npm run eject
pressy
to confirm. - Change Storybook config. Replace loadStories with:
function loadStories() {
// automatically import all story js files that end with *.stories.tsx
const req = require.context("../src", true, /\.stories\.tsx$/);
req.keys().forEach(filename => req(filename));
}
- Rename story file to
stories/index.stories.tsx
- Verify that it doesn’t recognize JSX-tag.
npm run storybook
Expected behavior I expected the same config that worked before ejecting would work after.
System:
- OS: MacOS Mojave and Windows 7
- Framework: React
- Version: Latest
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Webpack error adding storybook to create-react-app
I have the exact same issue with latest CRA/storybook, CRA not ejected thus webpack config hidden in node_modules and not customised. It seems ......
Read more >Stop Ejecting Create React App - YouTube
Instead of ejecting CRA ( Create # React App ) you can get access to many option by using Craco. In this lesson...
Read more >Create React App: import modules using aliases ... - Wavelop
You can take a look at a demo here. Initialize project using Create React App. Execute the following commands: npx create-react-app cra-with-module-alias ...
Read more >Frequently Asked Questions - Storybook - JS.ORG
If you have a question, you can ask it by opening an issue on the Storybook Repository ... Create React App does not...
Read more >Migrating a Create-React-App project into an Nx Workspace
The command above will detect that the project is generated with CRA, and that it has not been ejected, or _ customized_ with...
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
Hello! I’ve encountered the similiar issue and based on @mrmckeb response about separate configuration drafted a configuration that gave me the same behaviour which I had before ejecting CRA: https://github.com/storybookjs/presets/issues/72#issuecomment-584284246 Hope it’ll help someone who is in the same situation
Let me know if you need a hand with that, in the meantime I’ll close this off as it’s expected behaviour.
Also, consider forking
react-scripts
over ejection.