Skip to content

Instantly share code, notes, and snippets.

@SpadarShut
Created May 5, 2022 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpadarShut/c627cde9c8f8787274cf6637a12b3ea3 to your computer and use it in GitHub Desktop.
Save SpadarShut/c627cde9c8f8787274cf6637a12b3ea3 to your computer and use it in GitHub Desktop.
Config Storybook 6 + Tailwind 3 + next.js 12
const path = require("path")
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin")
module.exports = {
stories: ["../ui-kit/**/*.stories.mdx", "../@(modules|ui-kit)/**/*.stories.@(js|jsx|ts|tsx)"],
staticDirs: ["../public"],
core: {
builder: "webpack5",
},
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
managerEntries: ["@storybook/addon-postcss"],
framework: "@storybook/react",
webpackFinal: async (config) => {
// Support for TS aliases
config.resolve.plugins = config.resolve.plugins || []
config.resolve.plugins.push(new TsconfigPathsPlugin())
/**
* Fixes import with /
* @see https://github.com/storybookjs/storybook/issues/12844#issuecomment-867544160
*/
config.resolve.roots = [path.resolve(__dirname, "../public"), "node_modules"]
// Load tailwind styles
config.module.rules.push({
test: /\.css$/,
use: [
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [require("tailwindcss"), require("autoprefixer")],
},
},
},
],
include: path.resolve(__dirname, "../"),
})
return config
},
}
// And import global styles in .storybook/preview.js
// import "../styles/global.css"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment