Closed TheeMattOliver closed 1 year ago
Same here!
@mitikov I'm almost positive that once this is stable these issues will be addressed, but it's good for it to be documented here.
One short-term workaround the Storybook team suggests is trying this out with the Storybook 7 alpha. That requires some pretty significant re-configuration since 7.0 involves some breaking changes. Just know that if you do, it will probably break what you have :) (I haven't gotten it to work yet but didn't spend much time on it).
More details on that here: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md
@TheeMattOliver Thanks mate, I lost a herd of neurons while figuring out what is wrong =\
Sounds like the 3rd version should have not been published as primary (#38) at first place.
I'm fine to force good-old v2 and keep on living.
Regards / Nik
Thanks @mitikov for the solution to stick with v2
, I was about to go down the look-into-node_modules-code path. You saved me hours <3
Solution
If you only want to use tailwind, you can ignore & uninstall this(@storybook/addon-postcss
) plugin.
just import your tailwind css configuration into storybook/.preview.cjs
file like below
storybook/.preview.cjs
import '../src/style.css' // add this line
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
Yep, for any other Tailwind users, until this is stable, @storybook/addons-postcss@2
with Autoprefixer 9 works, e.g.:
// package.json
....
"devDependencies": {
"@babel/cli": "7.18.9",
"@babel/core": "^7.18.9",
"@babel/preset-env": "^7.18.9",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@storybook/addon-actions": "^6.5.10",
"@storybook/addon-essentials": "^6.5.10",
"@storybook/addon-interactions": "^6.5.10",
"@storybook/addon-links": "^6.5.10",
"@storybook/addon-postcss": "2",
"@storybook/builder-webpack4": "^6.5.10",
"@storybook/manager-webpack4": "^6.5.10",
"@storybook/react": "^6.5.10",
"@storybook/testing-library": "^0.0.13",
"@tailwindcss/postcss7-compat": "^2.2.17",
"@types/react": "^18.0.15",
"autoprefixer": "^9",
"babel-loader": "^8.2.5",
"postcss": "^8",
"postcss-loader": "4.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"tailwindcss": "npm:@tailwindcss/postcss7-compat",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"typescript": "^4.7.4"
},
...
The latest
tag has been moved back to 2.0.0
. (https://github.com/storybookjs/addon-postcss/issues/38#issuecomment-1213651620).
Describe the bug
@storybook/addon-postcss 3.0.0
throws an error and breaks Storybook, after following the instructions for configuring PostCSS 8 in the official Storybook docs.Steps to reproduce the behavior
Install minimal repro and attempt to run storybook
Expected behavior
To be able to run Storybook
Screenshots and/or logs
Environment
Temporary (not great) workaround is to downgrade
•
yarn add @storybook/addon-postcss@2
•yarn add autoprefixer@9
•yarn add postcss@9
•yarn add tailwindcss@2.0.1-compat
Additional context
There's some context in the discussion here.
preview.js
:main.js
:tsconfig.json
package.json
:Webpack info: