Skip to content

Commit ba78c5d

Browse files
committed
use webpack5 to build storybook
1 parent 53f94b2 commit ba78c5d

File tree

5 files changed

+1047
-95
lines changed

5 files changed

+1047
-95
lines changed

site/.babelrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"sourceType": "unambiguous",
3+
"presets": [
4+
[
5+
"@babel/preset-env",
6+
{
7+
"targets": {
8+
"chrome": 100
9+
}
10+
}
11+
],
12+
"@babel/preset-typescript",
13+
"@babel/preset-react"
14+
],
15+
"plugins": []
16+
}

site/.storybook/main.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
*
44
* @see <https://storybook.js.org/docs/react/configure/overview>
55
*/
6-
import type { StorybookConfig } from '@storybook/react-vite';
6+
const path = require("path");
7+
import type { StorybookConfig } from "@storybook/react-webpack5";
78
const config: StorybookConfig = {
89
// Automatically loads all stories in source ending in 'stories.tsx'
910
//
@@ -17,8 +18,7 @@ const config: StorybookConfig = {
1718
options: {
1819
actions: false
1920
}
20-
},
21-
],
21+
}],
2222
// SEE: https://storybook.js.org/docs/react/configure/babel
2323
babel: async options => ({
2424
...options,
@@ -30,16 +30,32 @@ const config: StorybookConfig = {
3030
//
3131
// SEE: https://storybook.js.org/docs/react/configure/overview#using-storybook-api
3232
staticDirs: ["../static"],
33-
typescript: { check: false },
33+
// Storybook internally uses its own Webpack configuration instead of ours.
34+
//
35+
// SEE: https://storybook.js.org/docs/react/configure/webpack
36+
webpackFinal: async config => {
37+
config.resolve!.modules = [path.resolve(__dirname, ".."), "node_modules", "../src"];
38+
return config;
39+
},
3440
framework: {
35-
name: "@storybook/react-vite",
41+
name: "@storybook/react-webpack5",
3642
options: {}
3743
},
3844
features: {
39-
storyStoreV7: true
45+
storyStoreV7: true,
46+
},
47+
core: {
48+
builder: {
49+
name: "@storybook/builder-webpack5",
50+
options: {
51+
lazyCompilation: true,
52+
fsCache: true,
53+
}
54+
}
4055
},
4156
docs: {
4257
autodocs: true
4358
}
4459
};
60+
4561
export default config

site/.storybook/preview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import "../src/i18n"
88
import React from "react"
99
import { Preview } from '@storybook/react';
1010

11-
1211
const themeProviderDecorator = (story) => (
1312
<ThemeProvider theme={dark}>
1413
<CssBaseline />

site/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,16 @@
9292
"yup": "0.32.11"
9393
},
9494
"devDependencies": {
95+
"@babel/preset-env": "^7.21.4",
96+
"@babel/preset-react": "^7.18.6",
97+
"@babel/preset-typescript": "^7.21.4",
9598
"@playwright/test": "1.29.2",
99+
"@storybook/addon-actions": "7.0.2",
96100
"@storybook/addon-essentials": "7.0.2",
97101
"@storybook/addon-links": "7.0.2",
102+
"@storybook/addon-mdx-gfm": "7.0.2",
98103
"@storybook/react": "7.0.2",
99-
"@storybook/react-vite": "7.0.2",
104+
"@storybook/react-webpack5": "^7.0.2",
100105
"@swc/core": "1.3.38",
101106
"@swc/jest": "0.2.24",
102107
"@testing-library/jest-dom": "5.16.5",
@@ -142,6 +147,7 @@
142147
"resize-observer": "1.0.4",
143148
"semver": "7.3.7",
144149
"storybook": "7.0.2",
150+
"storybook-addon-mock": "^4.0.0",
145151
"storybook-react-context": "^0.6.0",
146152
"typescript": "4.8.2"
147153
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy