How to add linaria to a project?
See original GitHub issueI have 6 storybook version want to add linaria plugin like this:
stories: [
'../packages/**/*.stories.mdx',
'../packages/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
babel: (config) => {
config.presets.push(require.resolve('linaria/babel'));
return config;
},
webpackFinal: async (config, { configType }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
presets: [
['react-app', { flow: false, typescript: true }],
require.resolve('linaria/babel'),
],
},
},
{
loader: 'linaria/loader',
options: {
sourceMap: process.env.NODE_ENV !== 'production',
},
},
],
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
},
};
As a result, I get an error: Module not found: Error: Can’t resolve ‘@storybook/react/types-6-0’ in ‘/Users/hazratgs/sberhealth/base-ui/packages/Button’
and WARNING in ./packages/Title/index.stories.tsx Module build failed (from ./node_modules/linaria/loader.js): SyntaxError: /Users/hazratgs/sberhealth/base-ui/packages/Title/index.stories.tsx: Unexpected token, expected “;” (26:2)
How do I add the plugin correctly? Tried different ways, he swears at types
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Linaria - Getting Started - Scott Spence
To start I'll spin up a new project with the Gatsby CLI: # with the Gatsby CLI gatsby ... Add Linaria and the...
Read more >Using Linaria for faster CSS-in-JS in React apps
Adding Linaria in React can be a daunting task. Unlike most CSS-in-JS libraries that require minimal setup, Linaria requires us to customize a ......
Read more >Create React App With Linaria - Better Programming
Next, we will add the Linaria loader to the Webpack config. First, install @linaria/webpack-loader : yarn add -D @linaria/webpack-loader. Open ...
Read more >Linaria – zero-runtime CSS in JS library
Zero-Runtime CSS in JS. Write CSS in JS and get real CSS files during build. Use dynamic prop based styles with the React...
Read more >linaria examples - CodeSandbox
Learn how to use linaria by viewing and forking linaria example apps on CodeSandbox. ... linaria-demoDemo project for linaria.now.sh.
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
My
.storybook/main.js
which works with @linaria/core@4.1.1 and @linaria/webpack5-loader@4.1.2 without external additional babel config file. Environment: yarn@3.2.2 with Workspaces and PnP.In my case, the above didn’t work. I had to tell Linaria exactly where my babel config was with the
babelOptions
key inside of the loader options. I also didn’t need to include thebabel
key in the storybook config export