Skip to content

Commit

Permalink
Refactor Storybook configuration to use Webpack 5 and update related …
Browse files Browse the repository at this point in the history
…dependencies
  • Loading branch information
vasapolrittideah committed Jan 23, 2025
1 parent ead75b8 commit 05bcc78
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 15 deletions.
Binary file modified bun.lockb
Binary file not shown.
47 changes: 39 additions & 8 deletions packages/ui/.storybook/main.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import path from 'path';
import { resolve } from 'path';

import type { StorybookConfig } from '@storybook/react-vite';
import type { StorybookConfig } from '@storybook/react-webpack5';
import autoprefixer from 'autoprefixer';
import tailwindcss from 'tailwindcss';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';

const config: StorybookConfig = {
stories: [
Expand All @@ -12,18 +15,46 @@ const config: StorybookConfig = {
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/addon-webpack5-compiler-swc',
],
framework: {
name: '@storybook/react-vite',
name: '@storybook/react-webpack5',
options: {},
},
viteFinal: async (config) => {
swc: () => ({
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
}),
webpackFinal: async (config) => {
if (config.resolve) {
config.resolve.alias = {
...config.resolve.alias,
'@': path.resolve(__dirname, '../src'),
};
config.resolve.plugins = [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
extensions: config.resolve.extensions,
}),
];
}

config.module?.rules?.push({
test: /\.css$/,
use: [
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [tailwindcss(), autoprefixer()],
},
},
},
],
include: resolve(__dirname, '../'),
});

return config;
},
};
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/.storybook/preview.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Preview } from '@storybook/react';
import '../lib/styles.css';
import '../global.css';

const preview: Preview = {
parameters: {
controls: {
disableSaveFromUI: true,
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
Expand Down
Binary file removed packages/ui/bun.lockb
Binary file not shown.
14 changes: 10 additions & 4 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"scripts": {
"build": "vite build",
"storybook": "storybook dev -p 6006",
"storybook": "storybook dev -p 6006 --debug",
"build-storybook": "storybook build",
"generate:component": "plop"
},
Expand All @@ -34,17 +34,21 @@
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-interactions": "^8.4.7",
"@storybook/addon-onboarding": "^8.4.7",
"@storybook/addon-webpack5-compiler-swc": "^2.0.0",
"@storybook/blocks": "^8.4.7",
"@storybook/builder-vite": "^8.5.1",
"@storybook/cli": "^8.5.1",
"@storybook/react": "^8.4.7",
"@storybook/react-vite": "^8.4.7",
"@storybook/react-webpack5": "^8.5.1",
"@storybook/test": "^8.4.7",
"@types/bun": "latest",
"@types/react": "^18.2.61",
"autoprefixer": "^10.4.18",
"plop": "^4.0.1",
"postcss": "^8.4.35",
"storybook": "^8.4.7",
"storybook": "8.5.1",
"tailwindcss": "^3.4.1",
"tsconfig-paths-webpack-plugin": "^4.2.0",
"typescript": "5.5.4",
"vite": "^6.0.11",
"vite-plugin-dts": "^4.5.0",
Expand All @@ -54,6 +58,8 @@
"typescript": "^5.0.0"
},
"dependencies": {
"ajv": "latest"
"ajv": "latest",
"crypto": "^1.0.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
2 changes: 1 addition & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"@/*": ["./src/*"]
}
},
"include": ["images.d.ts", "src", "lib", "lib/components.ts"],
"include": [".storybook", "images.d.ts", "src", "lib"],
"exclude": ["node_modules"]
}

0 comments on commit 05bcc78

Please sign in to comment.