feat(SW-3636): Storybook structure * New sections in Storybook sidebar * Group Storybook content files and add token files for spacing, border radius and shadows Approved-by: Joakim Jäderberg
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import type { StorybookConfig } from '@storybook/nextjs-vite'
|
|
import { mergeConfig } from 'vite'
|
|
|
|
const config: StorybookConfig = {
|
|
framework: '@storybook/nextjs-vite',
|
|
stories: [
|
|
'../lib/**/*.mdx',
|
|
'../lib/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
'./content/**/*.mdx',
|
|
],
|
|
addons: [
|
|
'@storybook/addon-links',
|
|
'@storybook/addon-themes',
|
|
'@storybook/addon-vitest',
|
|
'@storybook/addon-docs',
|
|
'@storybook/addon-a11y',
|
|
'storybook-react-intl',
|
|
],
|
|
core: {
|
|
disableTelemetry: true,
|
|
},
|
|
async viteFinal(config) {
|
|
return mergeConfig(config, {
|
|
plugins: [
|
|
// Add babel plugin for react-intl transformation
|
|
{
|
|
name: 'formatjs-transform',
|
|
async transform(code, id) {
|
|
if (id.includes('node_modules')) return
|
|
if (!/\.(jsx?|tsx?)$/.test(id)) return
|
|
|
|
const babel = await import('@babel/core')
|
|
const result = babel.transformSync(code, {
|
|
plugins: [
|
|
[
|
|
'formatjs',
|
|
{
|
|
idInterpolationPattern: '[sha512:contenthash:base64:6]',
|
|
ast: true,
|
|
},
|
|
],
|
|
],
|
|
filename: id,
|
|
})
|
|
|
|
return result?.code
|
|
},
|
|
},
|
|
],
|
|
})
|
|
},
|
|
}
|
|
export default config
|