我正在尝试在一个已经拥有大量 Webpack 2 配置的项目中使用 React Storybook。我按照以下基本步骤开始了故事书:
npm i -g @storybook/cli
getstorybook
当我运行时yarn storybook
,它会在演示组件的 JSX 上中断:
ERROR in ./stories/index.jsx
Module parse failed: /Users/alexanderhadik/project/web/node_modules/@storybook/react/node_modules/babel-loader/lib/index.js??ref--0!/Users/alexanderhadik/project/web/stories/index.jsx Unexpected token (9:55)
You may need an appropriate loader to handle this file type.
| import { Button, Welcome } from '@storybook/react/demo';
|
| storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
|
| storiesOf('Button', module)
@ ./.storybook/config.js 4:2-23
@ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js ./node_modules/webpack-hot-middleware/client.js?reload=true ./.storybook/config.js
由于我最初并没有使用这个项目开始create-react-app
- 我需要修改 Storybook webpack 配置以启用 JSX 吗?