|
| 1 | +import * as path from "path"; |
| 2 | +import { fileURLToPath } from "url"; |
| 3 | +import type { StorybookConfig } from "@storybook/react-webpack5"; |
| 4 | + |
| 5 | +const config: StorybookConfig = { |
| 6 | + stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], |
| 7 | + addons: [ |
| 8 | + "@storybook/addon-webpack5-compiler-swc", |
| 9 | + "@storybook/addon-onboarding", |
| 10 | + "@storybook/addon-links", |
| 11 | + "@storybook/addon-essentials", |
| 12 | + "@chromatic-com/storybook", |
| 13 | + "@storybook/addon-interactions", |
| 14 | + ], |
| 15 | + framework: { |
| 16 | + name: "@storybook/react-webpack5", |
| 17 | + options: {}, |
| 18 | + }, |
| 19 | + docs: { |
| 20 | + autodocs: "tag", |
| 21 | + }, |
| 22 | + swc: () => ({ |
| 23 | + jsc: { |
| 24 | + transform: { |
| 25 | + react: { |
| 26 | + runtime: "automatic", |
| 27 | + }, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }), |
| 31 | + webpackFinal: config => { |
| 32 | + return { |
| 33 | + ...config, |
| 34 | + resolve: { |
| 35 | + ...config.resolve, |
| 36 | + alias: { |
| 37 | + ...config.resolve?.alias, |
| 38 | + "@site": path.resolve(fileURLToPath(import.meta.url), "../.."), |
| 39 | + }, |
| 40 | + }, |
| 41 | + module: { |
| 42 | + ...config.module, |
| 43 | + rules: [ |
| 44 | + ...(config.module?.rules as Record<string, any>[]), |
| 45 | + { |
| 46 | + test: /\.(sa|sc|c)ss$/, // Test for .sass, .scss and .css files |
| 47 | + use: [ |
| 48 | + // MiniCssExtractPlugin.loader, // Extract css into separate files |
| 49 | + "style-loader", |
| 50 | + "css-loader", // Translates CSS into CommonJS |
| 51 | + { |
| 52 | + loader: "postcss-loader", // Loader for webpack to process CSS with PostCSS |
| 53 | + options: { |
| 54 | + postcssOptions: { |
| 55 | + ident: "postcss", |
| 56 | + plugins: [ |
| 57 | + require("postcss-import"), |
| 58 | + require("tailwindcss"), // use tailwindcss |
| 59 | + require("autoprefixer"), // add vendor prefixes |
| 60 | + ], |
| 61 | + }, |
| 62 | + }, |
| 63 | + }, |
| 64 | + "sass-loader", // Compiles Sass to CSS |
| 65 | + ], |
| 66 | + }, |
| 67 | + ], |
| 68 | + }, |
| 69 | + }; |
| 70 | + }, |
| 71 | +}; |
| 72 | +export default config; |
0 commit comments