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

Can't use JSX nor import CSS file in a custom addon #6047

Closed
mr-wildcard opened this issue Mar 12, 2019 · 6 comments
Closed

Can't use JSX nor import CSS file in a custom addon #6047

mr-wildcard opened this issue Mar 12, 2019 · 6 comments

Comments

@mr-wildcard
Copy link

mr-wildcard commented Mar 12, 2019

Describe the bug
I created a custom addon whose purpose is to print the HTML of the current viewed story. But it seems that I cannot import a CSS file nor use JSX in my addon.
Adding a custom webpack config with babel-loader, style-loader and css-loader doesn't fix this issue.

To Reproduce
Bug reproduction : https://github.com/mr-wildcard/storybook-custom-addon-bug-repro
Temporary fix : https://github.com/mr-wildcard/storybook-custom-addon-bug-repro/tree/temporay-fix

Expected behavior
Storybook should let me use JSX without any custom webpack config.
I might be wrong, but Storybook should also let me import a CSS file in my addon and process it out of the box.

Code snippets
see reproduction repository.

System:

  • OS: macOS 10.14.3
  • Device: Macbook Pro
  • Browser: Chrome
  • Framework: react
  • Addons: custom
  • Version: 5.0.1
@shilman
Copy link
Member

shilman commented Mar 12, 2019

cc @ndelangen

@tourshi
Copy link

tourshi commented Mar 25, 2019

I'm also experiencing this issue, v5.0.5

@shilman
Copy link
Member

shilman commented Mar 26, 2019

I'm not sure why the defaults are that way and I'll let @ndelangen field that.

As for customization, when you do typical "webpack customization" you're customizing the webpack in the preview, which is the area where your stories are rendered. However, addons are running in the manager which is the UI that wraps it. And it has its own webpack process and configuration.

For more info on customizing manager webpack post 4.1, see #4995

@mr-wildcard
Copy link
Author

Thank you @shilman . You're right, I was aware of the preview/manager distinction but didn't realize they were built using different webpack configurations.

I'll try @ndelangen solution 👍

@stale
Copy link

stale bot commented Apr 18, 2019

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 18, 2019
@github-actions
Copy link
Contributor

Automention: Hey @ndelangen, you've been tagged! Can you give a hand here?

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

4 participants