How to use babel-emotion-plugin with Storybook + Typescript?
See original GitHub issueI am currently using Storybook (v.4.0.12) with TypeScript and have successfully followed the instructions to set up my TypeScript webpack.config.js
. This works fine.
However, I cannot seem to find any way of successfully adding a babel plugin to the config. My latest attempt is below, which does not work.
module.exports = (baseConfig, env, config) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('awesome-typescript-loader'),
options: {
babelOptions: {
babelrc: false,
presets: [],
plugins: ['emotion'],
},
},
},
],
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
};
If I boot Storybook with this config, I continue to see the message Component selectors can only be used in conjunction with babel-plugin-emotion.
, which means that the Emotion babel plugin is not being picked up by Storybook.
I am not using CRA, just plain ol’ React and Typescript.
Any suggestions?
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:13
- Comments:17 (3 by maintainers)
Top Results From Across the Web
How to use babel-emotion-plugin with Storybook + Typescript?
If I boot Storybook with this config, I continue to see the message "Component selectors can only be used in conjunction with babel-plugin- ......
Read more >How to use babel-emotion-plugin with Storybook + Typescript?
I don't know if might solve your issue, but i got mine by just using this configuration in .storybook/main.js : module.exports = {...
Read more >Setting up Storybook with React, TypeScript and Emotion
Learn how to setup Storybook with React, TypeScript, and Emotion.
Read more >duncanleung/gatsby-typescript-emotion-storybook
duncanleung/gatsby-typescript-emotion-storybook. This Sandbox is in sync with master on GitHub. You have to fork to make changes. Fork. Files .storybook.
Read more >Babel - Storybook
Check out our source to learn more about these plugins. Custom config file. If your project has a .babelrc file, we'll use that...
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 Free
Top 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
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!
@MarkLyck crossposting it here from SO so other people might find it as well.
I don’t know if it applies to everyone, but in my case I got it working with storybook 5.3.x by using in
.storybook/main.js
this:This doesn’t use TypeScript tho, so might or might not be relevant in this situation, or might just be used while a solution using TypeScript is found.
Hope it helps.