Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create React App feature compatibility #3194

Closed
mattfysh opened this issue Mar 12, 2018 · 4 comments
Closed

Create React App feature compatibility #3194

mattfysh opened this issue Mar 12, 2018 · 4 comments

Comments

@mattfysh
Copy link

mattfysh commented Mar 12, 2018

Issue details

Strengthen compatibility between create-react-app and storybook build systems. There are some features of the CRA build (albeit, recent additions) which do not work with storybook (see steps to reproduce). Looking for any ideas here how to best get Storybook working with some of CRA's build features, plus any ideas to keep compatibility high as CRA grows.

Steps to reproduce

  1. create-react-app myapp
  2. add storybook to myapp
  3. add source code that uses babel macros, e.g. emotion/macro
  4. add source code that uses SVG component imports, e.g. import { ReactComponent as Logo } from './logo.svg'
  5. attempt to build source code with storybook

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/react 3.3.15

Affected platforms

Mac 10.13.3

Screenshots / Screencast / Code Snippets (Optional)

Currently using this in my .storybook/webpack.config.js

module.exports = config => {
  const babelLoader = config.module.rules.find(
    rule => rule.loader && rule.loader.indexOf('babel-loader') > 0
  )
  if (babelLoader) {
    babelLoader.query.plugins.unshift(require('babel-plugin-macros'))

    babelLoader.query.plugins.push([
      require.resolve('babel-plugin-named-asset-import'),
      {
        loaderMap: {
          svg: {
            ReactComponent: 'svgr/webpack![path]',
          },
        },
      },
    ])
  }

  config.module.rules.push({
    test: /\.svg$/,
    loader: require.resolve('file-loader'),
  })

  return config
}
@stale
Copy link

stale bot commented Apr 4, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Apr 4, 2018
@stale
Copy link

stale bot commented May 4, 2018

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed May 4, 2018
@craigcoles
Copy link

@mattfysh Did you ever find a solution to this issue? I am experiencing the same issue now.

@mattfysh
Copy link
Author

@craigcoles - only the .storybook/webpack.config.js from above, it works well enough for now

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants