Files
metabase/.storybook/main.ts
Fraser 355a5fc29c Use bun package manager (#68170)
* Use bun in package.json

* Update workflows

* Update more workflows

* Kick ci

* Fix yaml

* Fix type errors

* Compat with snyk

* Fix jest resolutions

* Add another esm package

* Fix aliases and next js missing deps

* Update next js embed tests

* Try fix embed test config

* Fix

* Fix requires in e2e support

* Use bun not yarn in embed bin

* Revert config changes

* Use bun in more scripts and use prepare-release action

* Replace more yarn usages

* Remove overrides from bunfig move to package json

* Revert e2e support changes

* Add back comment

* [ci skip] comment typo

* Update bun lock

* Update to reference bun

* Update to reference bun

* Update license disclaimer

* Tidy tests

* Update to use bun in workflows

* Change aliases

* Update codemirrort selector

* Tidy license generation

* Remove .only

* Fix yarn references

* Checkout .github for release scripts

* Update lockfile

* Re-add package

* update release bunlock

* fix checkout check

---------

Co-authored-by: Ryan Laurie <iethree@gmail.com>
2026-02-10 16:27:57 +00:00

96 lines
2.8 KiB
TypeScript

import type { StorybookConfig } from "@storybook/react-webpack5";
const appConfig = require("../rspack.main.config.js");
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CSS_CONFIG } = require("../frontend/build/shared/rspack/css-config");
const mainAppStories = [
"../frontend/**/*.mdx",
"../frontend/**/*.stories.@(js|jsx|ts|tsx)",
"../enterprise/frontend/**/*.stories.@(js|jsx|ts|tsx)",
];
// Allow filtering to specific story files via env var (used by stress tests)
// STORYBOOK_STORIES_FILTER: comma-separated file paths relative to repo root
// e.g. "frontend/src/.../Button.stories.tsx,frontend/src/.../Alert.stories.tsx"
const stories = process.env.STORYBOOK_STORIES_FILTER
? process.env.STORYBOOK_STORIES_FILTER.split(",").map((f) => `../${f}`)
: mainAppStories;
const config: StorybookConfig = {
stories,
staticDirs: ["../resources/frontend_client", "./msw-public"],
addons: [
"@storybook/addon-webpack5-compiler-babel",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-links",
"@storybook/addon-a11y",
"storybook-addon-pseudo-states",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
typescript: {
reactDocgen: "react-docgen-typescript",
},
webpackFinal: (config) => {
return {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
...appConfig.resolve.alias,
},
extensions: appConfig.resolve.extensions,
fallback: {
...config.resolve?.fallback,
...appConfig.resolve.fallback,
},
},
plugins: [
...(config.plugins ?? []),
new MiniCssExtractPlugin({
ignoreOrder: true,
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new webpack.EnvironmentPlugin({
IS_EMBEDDING_SDK: "false",
}),
],
module: {
...config.module,
rules: [
...(config.module?.rules ?? []).filter(
(rule) => !isCSSRule(rule) && !isSvgRule(rule),
),
...appConfig.module.rules.filter((rule: any) => isSvgRule(rule)),
// We use MiniCssExtractPlugin, because Storybook can't properly work with `rspack.CssExtractRspackPlugin`
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: { publicPath: "./" },
},
{ loader: "css-loader", options: CSS_CONFIG },
{ loader: "postcss-loader" },
],
},
],
},
};
},
};
export default config;
const isCSSRule = (rule: any) => rule.test?.toString() === "/\\.css$/";
const isSvgRule = (rule: any) => rule.test?.test(".svg");