Skip to content

Commit 40619bb

Browse files
committed
Update Storybook fully and move it to TS
1 parent 8f70bf2 commit 40619bb

File tree

13 files changed

+646
-565
lines changed

13 files changed

+646
-565
lines changed

.babelrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
["@babel/preset-react", { "runtime": "automatic" }],
4+
"@babel/preset-typescript"
5+
]
6+
}

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77

88
strategy:
99
matrix:
10-
node-version: [14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
10+
node-version: ["24.x"]
1111

1212
steps:
1313
- uses: actions/checkout@v4
@@ -21,8 +21,7 @@ jobs:
2121
- run: npm run build-storybook --quiet
2222

2323
- uses: actions/upload-artifact@v4
24-
# Only publish examples using the main branch, and only from one build
25-
if: github.ref == 'refs/heads/main' && matrix.node-version == '24.x'
24+
if: github.ref == 'refs/heads/main'
2625
with:
2726
name: examples
2827
path: examples/*

.storybook/addons.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

.storybook/config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

.storybook/main.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
stories: ['../stories/**/*.stories.@(js|jsx|tsx)'],
3+
addons: ['@storybook/addon-docs'],
4+
framework: {
5+
name: '@storybook/react-webpack5',
6+
options: {},
7+
},
8+
docs: {
9+
autodocs: true,
10+
},
11+
typescript: {
12+
check: true,
13+
reactDocgen: false,
14+
},
15+
webpackFinal: async (config) => {
16+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
17+
18+
// Ensure babel-loader processes story files
19+
config.module.rules.push({
20+
test: /\.(ts|tsx|js|jsx)$/,
21+
include: /stories/,
22+
use: [{
23+
loader: require.resolve('babel-loader'),
24+
options: {
25+
presets: [
26+
[require.resolve('@babel/preset-react'), { runtime: 'automatic' }],
27+
require.resolve('@babel/preset-typescript')
28+
]
29+
}
30+
}]
31+
});
32+
33+
// Add TypeScript type checking
34+
config.plugins.push(
35+
new ForkTsCheckerWebpackPlugin({
36+
typescript: {
37+
configFile: require('path').resolve(__dirname, '../stories/tsconfig.json'),
38+
},
39+
})
40+
);
41+
42+
return config;
43+
},
44+
};

.storybook/preview.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const parameters = {
2+
docs: {
3+
codePanel: true,
4+
},
5+
};

.storybook/webpack.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"pretest": "npm run build",
1717
"test": "echo \"It built ok, that'll do for now\"",
1818
"prepare": "npm run build",
19-
"storybook": "start-storybook -p 6006",
20-
"build-storybook": "build-storybook -o examples"
19+
"storybook": "storybook dev -p 6006",
20+
"build-storybook": "storybook build -o examples"
2121
},
2222
"repository": {
2323
"type": "git",
@@ -40,17 +40,22 @@
4040
"homepage": "https://github.com/httptoolkit/react-reverse-portal#readme",
4141
"devDependencies": {
4242
"@babel/core": "^7.5.5",
43-
"@storybook/addon-storysource": "~5.1.11",
44-
"@storybook/addons": "~5.1.11",
45-
"@storybook/react": "~5.1.11",
43+
"@babel/preset-react": "^7.27.1",
44+
"@babel/preset-typescript": "^7.27.1",
45+
"@storybook/addon-docs": "^9.1.10",
46+
"@storybook/preset-react-webpack": "^9.1.10",
47+
"@storybook/react": "^9.1.10",
48+
"@storybook/react-webpack5": "^9.1.10",
4649
"@types/events": "^3.0.0",
4750
"@types/node": "^24.6.2",
48-
"@types/react": "^16.9.2",
49-
"@types/react-dom": "^16.9.0",
51+
"@types/react": "^18.3.1",
52+
"@types/react-dom": "^18.3.1",
5053
"babel-loader": "^8.0.6",
51-
"react": "^16.9.0",
52-
"react-dom": "^16.9.0",
54+
"fork-ts-checker-webpack-plugin": "^9.1.0",
55+
"react": "^18.3.1",
56+
"react-dom": "^18.3.1",
5357
"rimraf": "^3.0.0",
58+
"storybook": "^9.1.10",
5459
"typescript": "^5.9.3"
5560
},
5661
"peerDependencies": {

0 commit comments

Comments
 (0)