-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Storybook doesn't work with the newest version 10.0.1 of PostCSS Autoprefixer plugin #12668
Comments
Having the exact same issue when trying to make my postcss config work. It won't allow |
I could workaround this by adding:
to my package.json. With that I can successfully use Tailwind 2.0 inside storybook. Edit: There is a better solution: #12668 (comment). |
@4lejandrito would you mind sharing your storybook setup or a sample repo on this setup.. I am having trouble getting my tailwind 2.0 working with postcss@8 |
At the end I followed the instructions at https://tailwindcss.com/docs/installation#post-css-7-compatibility-build and everything works like a charm without dirty hacks. I created a sample project: https://github.com/4lejandrito/storybook-tailwind2. |
@4lejandrito thanks you so much for taking the time to set up the sample repo for reference. I did try the instructions for post-css-7-compatibility-build.. However, I was getting some weird errors.. I am trying to use this as part of rushjs monorepo.. Tried your repo and it is working perfectly fine.. Will try to incorporate my stories to yours and see if it works.. |
The workaround with |
Hey @aantipov at the end I didn't need to use
|
Hi, I've a similar issue with (Non minimal) reproduction here: https://github.com/VulcanJS/vulcan-next/tree/bugfix/styled-jsx-postcss-storybook-build-fail, in Edit: I've cross-posted to Next github where it is probably more suited. |
I was using tsdx for building a react component library and it is throwing errors even after setting up this for PostCSS 7. Got it working with non tsdx version easily with the sample @4lejandrito shared. |
it was more of a tailwind issue than of tsdx. tailwindlabs/tailwindcss#2795. got it working by commenting the |
The |
Great news @eric-burel ! Awesome job figuring that out. Thanks to you we're one step closer to a first class nextjs/storybook integration 🎉 |
As a workaround for TailwindCSS, I opted to first, build out the CSS and then adding it to the ( |
Hey @dazuaz I tried following your example repo but storybook still trigger tailwind build when ran. I understand your reasoning here but I don't get how you stop tailwind from doing that. Still same error: PostCSS plugin tailwindcss requires PostCSS 8 |
@kawinie Are you able to run storybook will trigger tailwind build if you import it in Are you able to clone the repo and run it? |
There is an incompatibility between storybook and the latest version of postcss (see: storybookjs/storybook#12668) which we didn't notice because we weren't generating the actual storybook in CI.
There is an incompatibility between storybook and the latest version of postcss (see: storybookjs/storybook#12668) which we didn't notice because we weren't generating the actual storybook in CI.
@dazuaz It seems like storybook itself looks for |
It seems like a lot of workarounds depend on Tailwind, but for anyone who ends up here in despair, this is unrelated to Tailwind, so it may happen to you (as it does to us) even if you're not using Tailwind. In our case, we're using plain PostCSS with Autoprefixer, postcss-url, etc. Thanks everyone! |
Thank you @dazuaz, this approach fixed my issue. I'm using Storybook with NextJS ( but not tailwind ) and I was facing this error:
The approach you show in your repo helped me getting rid of it. |
I also had an issue with tailwind in storybook, ended up doing this ugliness, but it works:
Specify somewhere that we are running a storybook
Disable tailwind postcss plugin if running within a storybook context
|
when I do |
I tried
However, I got an error that PostCSS 8 was not being used.
~
src/styles/global.css ("tailwindcss": "2.0.2")
|
I also get the same issue as @matamatanot (also with tailwind 2.0.2) I might have missed something from my config after doing
It's really not very clear what needs to be changed (if anything) to this to get storybook working with postcss 8 other than running the above command Any guidance would be great but right now there's no difference than running the current version of sb, with my app running normally on postcss 8, but storybook failing.
Edit: Looks like Solution:
your package.json should now look like this
your package.json should now look like this
|
@danspratling Thanks for the guide! You are correct that |
@seonghyeonkimm sorry for the confusion. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@dominikhaid this is already fixed in the prerelease + installing the |
For people just getting to this thread, #12668 (comment) is a guide on using new postcss with the prerelease of storybook 6.2 |
In relation to
|
@larsenwork apologies. fixing with the release of |
|
I'm runnning Storybook 6.2.9 + NextJS 10 + Tailwind 2 and although the What worked for me was downgrading tailwind as per #12668 (comment). |
Got running in 6.2.9 with #12668 (comment) , but after upgrading to 6.3.0 error is back. |
Same for Next.js 11 and Tailwind 2 |
I explicitly added webpack@5 to my packages and my Next 11 / tailwind2 app works again. |
This did it for me. |
@CodyBontecou thanks a lot for the repo. I also got it working following the instructions. Much appreciate your efforts. Regards.. |
Hello all! I'm still having this issue after following several of the above suggested solutions. I'm wondering if it's a version thing? Here's what I've got: package.json: ...
"devDependencies": {
"@babel/core": "^7.18.6",
"@bbbtech/storybook-formik": "^2.5.0",
"@storybook/addon-actions": "^6.5.9",
"@storybook/addon-essentials": "^6.5.9",
"@storybook/addon-interactions": "^6.5.9",
"@storybook/addon-links": "^6.5.9",
"@storybook/builder-webpack5": "^6.5.9",
"@storybook/manager-webpack5": "^6.5.9",
"@storybook/react": "^6.5.9",
"@storybook/testing-library": "^0.0.13",
"@tailwindcss/forms": "^0.5.1",
"@tailwindcss/typography": "^0.5.2",
...
"postcss": "^8.4.13",
...
"storybook-addon-next": "^1.6.7",
"tailwindcss": "^3.0.24",
...
},
... main.js const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
stories: [
"../components/**/*.stories.@(js|jsx|ts|tsx)",
"../features/**/*.stories.@(js|jsx|ts|tsx)"
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"storybook-formik/register",
{
name: '@storybook/addon-postcss',
options: {
postcssLoaderOptions: {
implementation: require('postcss'),
},
},
},
"storybook-addon-next",
],
core: {
builder: 'webpack5',
},
framework: "@storybook/react",
webpackFinal: async (config, { configType }) => {
config.resolve.plugins = [new TsconfigPathsPlugin()];
return config;
}
} preview.js import "../styles/globals.css";
module.exports = {
stories: ["../components/**/*.stories.@(js|jsx|ts|tsx)", "../features/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
// docs panel as default
previewTabs: {
"storybook/docs/panel": { index: -1 },
},
framework: "@storybook/react",
parameters: {
backgrounds: {
default: "gray-100",
values: [
{ name: "gray-100", value: "#f3f4f6" },
{ name: "blue-900", value: "#061146" },
],
},
},
}; It looks like all my versions are newer than the ones listed in the issue history here. |
@mct-dev - Have you taken a look in your package-lock.json (or yarn.lock) file to see what has been installed? You could try deleting that file and trying the install again - I had a similar issue recently, where it kept reinstalling the old version due to the lock file. |
This almost works for me, but i seem to not be able to compile .css files that use |
Seems like for version bumps solution posted above might not be a feasible solution. For the Tailwindcss version > Adding the following import in the preview.js file under story book configuration. import '!style-loader!css-loader!postcss-loader!tailwindcss/tailwind.css'; Original Solution posted here Overall setup:Dependencies"devDependencies": {
"@babel/core": "^7.21.0",
"@storybook/addon-actions": "^6.5.16",
"@storybook/addon-essentials": "^6.5.16",
"@storybook/addon-interactions": "^6.5.16",
"@storybook/addon-links": "^6.5.16",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/testing-library": "^0.0.13",
"autoprefixer": "^10.4.13",
"babel-loader": "^8.3.0",
"eslint-plugin-storybook": "^0.6.11",
"plop": "^3.1.2",
"postcss": "^8.4.21",
"storybook-css-modules-preset": "^1.1.1",
"tailwindcss": "^3.2.7"
}, .storybook/main.jsmodule.exports = {
stories: ['../**/*.stories.mdx', '../**/*.stories.@(js|jsx|ts|tsx)'],
staticDirs: ['../public'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'storybook-css-modules-preset',
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-webpack5',
},
}; .storybook/preview.jsimport '!style-loader!css-loader!postcss-loader!tailwindcss/tailwind.css';
// your other configurations . . . |
Describe the bug
Storybook is failing to build itself when using newest versions of
autoprefixer
,postcss
andpostcss-loader
To Reproduce
Steps to reproduce the behavior:
autoprefixer
(10.0.1),postcss
(8.1.1) andpostcss-loader
(4.0.3)postcss-loader
)System
Please paste the results of
npx sb@next info
here.Additional context
It looks like the problem comes from the fact that Storybook uses it's own version of
postcss-loader
, which comes with it's own version7.x
ofpostcss
One solution that I see is to update
postcss-loader
andpostcss
Another - provide a way to use project's versions of
postcss-loader
andpostcss
dependenciesThe text was updated successfully, but these errors were encountered: