Closed aantipov closed 3 years ago
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 @apply bg-primary mt-10
.
they seem to be ommited from the files.
Seems like for version bumps solution posted above might not be a feasible solution.
For the Tailwindcss version >3.*.*
and Storybook version > 6.5.*
along with postcss version of 8.*
, the followign steps worked or me:
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
"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"
},
module.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',
},
};
import '!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 updatepostcss-loader
andpostcss
Another - provide a way to use project's versions ofpostcss-loader
andpostcss
dependencies