question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next.js 10 webpack5 + Storybook 6.2.9 + Tailwind / Not loading CSS

See original GitHub issue

Hi, I’ve installed storybook on Next.js 10 with webpack5 + Storybook 6.2.9 + Tailwind, but I can’t see the CSS styles, as you can see in this image:

image

main.js

module.exports = {
  stories: [
    '../components/**/*.stories.mdx',
    '../components/**/*.stories.@(js|jsx|ts|tsx)',
    '../components/stories/*.stories.@(js|jsx|ts|tsx)',
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/preset-create-react-app',

    {
      name: '@storybook/addon-postcss',
      options: {
        postcssLoaderOptions: {
          implementation: require('postcss'),
        },
      },
    },
  ],

  webpackFinal: (config) => {
    config.module.rules.push({
      test: /\.scss$/,
      sideEffects: true,
      use: ['react-style-loader', 'css-loader', 'sass-loader'],
    })

    return config
  },
}

I check all github related issues, but I don’t want to downgrade Tailwind to use Storybook, is there anything I can do?

Thanks in advance!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sshquackcommented, Mar 28, 2022

No luck. I got rid of storybook and moved to Ladle (by Uber team). Ladle is built on Vite and it works out of the box with TailwindCSS and it’s blazing fast!

Note that storybook-postcss plugin has pretty much been abandoned (last commit 2021 Jan) and the storybook team has other priorities. So the chances of all the issues in this repo getting fixed is pretty low. So use best judgment.

1reaction
sshquackcommented, Jan 4, 2022

After following the addon-postcss I’m seeing this error too. SB fails to build with CRA TW and SB with this error:

99% done plugins webpack-hot-middlewarewebpack built preview 5f7ac74125465130ad66 in 4135ms
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
SyntaxError

(1:1) /Users/ayemacair/Desktop/code/js/react-ts-tw-sb-01/src/index.css Unknown word

> 1 | var api = require("!../node_modules/@storybook/addon-postcss/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
...

Deps:

Full repro: https://github.com/sshquack/react-ts-tw-sb-01

Any idea on how to get past this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use SCSS and Tailwind CSS with Storybook in ...
Look into the .storybook folder, styles folder and postcss.config.js file specifically. What is in this repo works with Storybook, but not ...
Read more >
How to set up Storybook with Next.js and Tailwind CSS
This step-by-step tutorial is written with Storybook v6.4.9 & TypeScript, if you found the tutorial is not working after some minor update, ...
Read more >
Storybook With Tailwind And Emotion Setup - ADocLib
Unable to run Storybook after installing TailwindCSS [Stack: NextJS11 PrismicCMS with ... Next.js 10 webpack5 + Storybook 6.2.9 + Tailwind / Not loading...
Read more >
storybook digital envelope routines::unsupported
createHash (node:crypto:133:10) at module.exports (/home/embold/code/handshaked/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule.
Read more >
Storybook for Webpack 5 - JS.ORG
So upgrading to Webpack 5 not only helps push the web forward, but also has immediate benefits to Storybook users: Ecosystem compatibility ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found