wcb/storybook/.storybook/main.js
Ayo 2da6cd5afc
Some checks are pending
Tests / Unit (push) Waiting to run
Tests / E2E (push) Waiting to run
feat: new cem analyzer plugin (cem-plugin)
2026-07-19 21:06:22 +02:00

41 lines
1.4 KiB
JavaScript

import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const repo = resolve(root, '..')
const srcDir = resolve(repo, 'src')
/** @type {import('@storybook/web-components-vite').StorybookConfig} */
export default {
stories: ['../stories/**/*.stories.js', '../stories/**/*.mdx'],
addons: ['@storybook/addon-docs'],
framework: { name: '@storybook/web-components-vite', options: {} },
// Same aliasing the demo uses: resolve the library to `src/` so stories get
// instant HMR against the real source instead of the built bundle. (The CEM
// config deliberately does the opposite and imports the plugin from `dist/`
// via its published subpath.)
viteFinal: (config) => ({
...config,
resolve: {
...config.resolve,
alias: [
...(config.resolve?.alias ?? []),
{
find: /^web-component-base\/utils$/,
replacement: resolve(srcDir, 'utils/index.js'),
},
{
find: /^web-component-base\/html$/,
replacement: resolve(srcDir, 'html.js'),
},
{
find: /^web-component-base$/,
replacement: resolve(srcDir, 'index.js'),
},
],
},
// stories import components from the sibling `demo/` workspace
server: { ...config.server, fs: { allow: [repo] } },
}),
}