-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Vite for Storybook, instead of webpack
- Loading branch information
Showing
4 changed files
with
524 additions
and
1,345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,17 @@ | ||
import path from 'node:path'; | ||
import type {StorybookConfig} from '@storybook/react-webpack5'; | ||
import type {StorybookConfig} from '@storybook/react-vite'; | ||
|
||
export default { | ||
addons: [ | ||
'@storybook/addon-a11y', | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-webpack5-compiler-swc', | ||
], | ||
core: { | ||
disableTelemetry: true, | ||
}, | ||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {}, | ||
}, | ||
stories: ['../app'], | ||
|
||
swc: () => ({ | ||
jsc: { | ||
transform: { | ||
react: { | ||
runtime: 'automatic', | ||
}, | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: { | ||
builder: { | ||
viteConfigPath: 'vite.storybook.config.ts', | ||
}, | ||
}, | ||
}), | ||
|
||
webpackFinal(config) { | ||
return { | ||
...config, | ||
|
||
resolve: { | ||
...config.resolve, | ||
alias: { | ||
...config.resolve?.alias, | ||
// Custom path aliases. Keep in sync with `paths` in tsconfig.json. | ||
'~': path.resolve(__dirname, '../app'), | ||
tests: path.resolve(__dirname, '../tests'), | ||
}, | ||
fallback: { | ||
...config.resolve?.fallback, | ||
// Suppress un-polyfilled module warning from @sinonjs/fake-timers. | ||
timers: false, | ||
}, | ||
}, | ||
|
||
module: { | ||
...config.module, | ||
rules: [ | ||
...(config.module?.rules || []), | ||
// Replace @remix-run/node with an empty file. It should never be used by browser code. | ||
{ | ||
test: require.resolve('@remix-run/node'), | ||
use: 'null-loader', | ||
}, | ||
// Replace `.server.ts` files with an empty file. Remix will never send these to the | ||
// browser. | ||
{ | ||
test: /\.server/, | ||
use: 'null-loader', | ||
}, | ||
// Integrate Tailwind. Remix handles this when running the app, but we need to configure it | ||
// ourselves in Storybook. | ||
{ | ||
test: /\.css$/i, | ||
use: ['postcss-loader'], | ||
}, | ||
], | ||
}, | ||
}; | ||
}, | ||
core: { | ||
disableTelemetry: true, | ||
}, | ||
addons: ['@storybook/addon-a11y', '@storybook/addon-essentials'], | ||
} satisfies StorybookConfig; |
Oops, something went wrong.