1- import type { StorybookConfig } from '@storybook/nextjs' ;
2- import classNames from 'classnames' ;
1+ import { join } from 'node:path' ;
32
4- const rootClasses = classNames (
5- // note: this is hard-coded sadly as next/font can only be loaded within next.js context
6- '__variable_open-sans-normal' ,
7- // note: this is hard-coded sadly as next/font can only be loaded within next.js context
8- '__variable_ibm-plex-mono-normal'
9- ) ;
3+ import type { StorybookConfig } from '@storybook/react-webpack5' ;
4+
5+ const mocksFolder = join ( __dirname , '../components/__mocks__' ) ;
106
117const config : StorybookConfig = {
128 stories : [ '../components/**/*.stories.tsx' ] ,
139 logLevel : 'error' ,
1410 staticDirs : [ '../public' ] ,
1511 typescript : { reactDocgen : false , check : false } ,
1612 core : { disableTelemetry : true , disableWhatsNewNotifications : true } ,
17- framework : {
18- name : '@storybook/nextjs' ,
19- options : { builder : { useSWC : true } } ,
20- } ,
21- previewBody :
22- // This `<style>` is necessary to simulate what `next-themes` (ThemeProvider) does on real applications
23- // `next-theme` automatically injects the color-scheme based on the system preference or the current applied theme
24- // on Storybook we don't use `next-theme` as we want to simulate themes
25- '<style>:root { color-scheme: light; } html[data-theme="dark"] { color-scheme: dark; }</style>' +
26- // This adds the base styling for dark/light themes within Storybook. This is a Storybook-only style
27- `<body class="${ rootClasses } "></body>` ,
13+ framework : '@storybook/react-webpack5' ,
14+ swc : ( ) => ( { jsc : { transform : { react : { runtime : 'automatic' } } } } ) ,
2815 addons : [
16+ '@storybook/addon-webpack5-compiler-swc' ,
2917 '@storybook/addon-controls' ,
3018 '@storybook/addon-interactions' ,
3119 '@storybook/addon-themes' ,
3220 '@storybook/addon-viewport' ,
21+ {
22+ name : '@storybook/addon-styling-webpack' ,
23+ options : {
24+ rules : [
25+ {
26+ test : / \. c s s $ / ,
27+ use : [
28+ 'style-loader' ,
29+ { loader : 'css-loader' , options : { url : false } } ,
30+ 'postcss-loader' ,
31+ ] ,
32+ } ,
33+ ] ,
34+ } ,
35+ } ,
3336 ] ,
3437 webpack : async config => ( {
3538 ...config ,
@@ -39,7 +42,15 @@ const config: StorybookConfig = {
3942 performance : { hints : false } ,
4043 // `nodevu` is a Node.js-specific package that requires Node.js modules
4144 // this is incompatible with Storybook. So we just mock the module
42- resolve : { ...config . resolve , alias : { '@nodevu/core' : false } } ,
45+ resolve : {
46+ ...config . resolve ,
47+ alias : {
48+ '@nodevu/core' : false ,
49+ 'next-intl/navigation' : join ( mocksFolder , './next-intl.mjs' ) ,
50+ '@/client-context' : join ( mocksFolder , './client-context.mjs' ) ,
51+ '@' : join ( __dirname , '../' ) ,
52+ } ,
53+ } ,
4354 // We need to configure `node:` APIs as Externals to WebPack
4455 // since essentially they're not supported on the browser
4556 externals : {
0 commit comments