Skip to content

Instantly share code, notes, and snippets.

@mujsdev
Last active December 10, 2022 22:55
Show Gist options
  • Save mujsdev/f58360fdf3c011a959ee039465445d71 to your computer and use it in GitHub Desktop.
Save mujsdev/f58360fdf3c011a959ee039465445d71 to your computer and use it in GitHub Desktop.
main.js config for Storybook
const path = require("path");
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx|mdx)"],
/** Expose public folder to storybook as static */
staticDirs: ["../public"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
{
name: "@storybook/addon-postcss",
options: {
postcssLoaderOptions: {
implementation: require("postcss"),
},
},
},
],
core: {
builder: "webpack5",
},
framework: "@storybook/react",
webpackFinal: async (config) => {
config.resolve.extensions.push(".ts", ".tsx");
// SASS + Tailwdind CSS
config.module.rules.push({
test: /\.s(a|c)ss$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1, // We always need to apply postcss-loader before css-loader
modules: {
auto: /\.module\.scss$/, // true
localIdentName: "[name]__[local]--[hash:base64:5]",
},
},
},
{
loader: "postcss-loader", // required for tailwind
options: {
implementation: require("postcss"), // postcss 8
postcssOptions: {
config: path.resolve(__dirname, "../postcss.config.js"),
},
},
},
{
loader: "sass-loader",
options: {
// sourceMap: true,
implementation: require("sass"), // dart sass
},
},
],
});
return config;
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment