forked from jpmorganchase/salt-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
64 lines (57 loc) · 1.84 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type { StorybookConfig } from "@storybook/react/types";
import type { UserConfig } from "vite";
import { mergeConfig } from "vite";
import { cssVariableDocgen } from "css-variable-docgen-plugin";
import { typescriptTurbosnap } from "vite-plugin-typescript-turbosnap";
type ViteFinalOptions = {
configType: "DEVELOPMENT" | "PRODUCTION";
};
interface ExtendedConfig extends StorybookConfig {
viteFinal?: (
config: UserConfig,
options: ViteFinalOptions
) => Promise<UserConfig>;
}
const config: ExtendedConfig = {
framework: "@storybook/react",
stories: ["../packages/*/stories/**/*.stories.@(js|jsx|ts|tsx|mdx)"],
staticDirs: ["../docs/public"],
addons: [
{
name: "@storybook/addon-essentials",
options: {
// We don't want the backgrounds addon as our own withThemeBackground works with theme switch to apply background
backgrounds: false,
},
},
"@storybook/addon-links",
"@storybook/addon-a11y",
"@storybook/addon-storysource",
// Keep in mind this is not v1 yet. Might encounter bugs. It's from atlassian labs, so not too much concern.
// Temporarily disable this due to run time error "Cannot read property 'context' of undefined" from Topbar
// 'storybook-addon-performance/register',
],
core: {
builder: "@storybook/builder-vite",
},
features: {
postcss: false,
// modernInlineRender: true,
storyStoreV7: true,
buildStoriesJson: true,
// babelModeV7: true,
},
async viteFinal(config, { configType }) {
// customize the Vite config here
const customConfig: UserConfig = {
plugins: [cssVariableDocgen()],
};
if (configType === "PRODUCTION") {
customConfig.plugins!.push(
typescriptTurbosnap({ rootDir: config.root! })
);
}
return mergeConfig(customConfig, config);
},
};
module.exports = config;