-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ♻️ Update Babel configuration for Storybook compatibility a…
…nd make Storybook work with webpack
- Loading branch information
1 parent
8699292
commit 14c15aa
Showing
11 changed files
with
1,503 additions
and
3,444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
|
||
import configFactory from "../config/webpack.config"; | ||
|
||
import { mergeUniqueArrays } from "../utils"; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
|
||
webpackFinal: async (config, { configType }) => { | ||
const customWebpackConfig = configFactory(configType?.toLocaleLowerCase() || "development"); | ||
|
||
if (configType === "DEVELOPMENT") { | ||
// Modify config for development | ||
} | ||
if (configType === "PRODUCTION") { | ||
// Modify config for production | ||
} | ||
|
||
if (config.resolve) { | ||
if (config.resolve.modules) | ||
config.resolve.modules = mergeUniqueArrays(config.resolve.modules, customWebpackConfig.resolve.modules); | ||
|
||
if (config.resolve.extensions) | ||
config.resolve.extensions = mergeUniqueArrays( | ||
config.resolve.extensions, | ||
customWebpackConfig.resolve.extensions | ||
); | ||
} | ||
|
||
if (config.module?.rules) { | ||
config.module.rules.push({ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: "postcss-loader", | ||
options: { | ||
postcssOptions: { | ||
plugins: [require("tailwindcss")], | ||
}, | ||
}, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
return config; | ||
}, | ||
addons: [ | ||
"@storybook/addon-webpack5-compiler-swc", | ||
"@storybook/addon-onboarding", | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@chromatic-com/storybook", | ||
"@storybook/addon-interactions", | ||
"@storybook/addon-styling-webpack", | ||
"@storybook/addon-themes", | ||
"@storybook/addon-a11y", | ||
"@storybook/addon-webpack5-compiler-babel", | ||
], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
staticDirs: ["../public"], | ||
docs: {}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.