mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 10:59:53 +00:00
Add stories for the media assets sidebar tab for easier prototyping. Includes mocks for storybook. Because some functions in the mocks are only used in the storybook main.ts resolve, knip flags them as unused because it doesn't check that path. So knipIgnoreUnusedButUsedByStorybook was added. Part of the QPO v2 iteration, figma design can be found [here](https://www.figma.com/design/LVilZgHGk5RwWOkVN6yCEK/Queue-Progress-Modal?node-id=3330-37286&m=dev). This will be implemented in a series of stacked PRs that can be reviewed and merged individually. main <-- #7737, #7743, #7745 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7743-QPOv2-Add-stories-for-list-view-and-general-job-card-2d26d73d365081bca59afa925fb232d7) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com>
132 lines
4.0 KiB
TypeScript
132 lines
4.0 KiB
TypeScript
import type { StorybookConfig } from '@storybook/vue3-vite'
|
|
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
|
|
import IconsResolver from 'unplugin-icons/resolver'
|
|
import Icons from 'unplugin-icons/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import type { InlineConfig } from 'vite'
|
|
|
|
const config: StorybookConfig = {
|
|
stories: ['../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
addons: ['@storybook/addon-docs', '@storybook/addon-mcp'],
|
|
framework: {
|
|
name: '@storybook/vue3-vite',
|
|
options: {}
|
|
},
|
|
async viteFinal(config) {
|
|
// Use dynamic import to avoid CJS deprecation warning
|
|
const { mergeConfig } = await import('vite')
|
|
const { default: tailwindcss } = await import('@tailwindcss/vite')
|
|
|
|
// Filter out any plugins that might generate import maps
|
|
if (config.plugins) {
|
|
config.plugins = config.plugins
|
|
// Type guard: ensure we have valid plugin objects with names
|
|
.filter(
|
|
(plugin): plugin is NonNullable<typeof plugin> & { name: string } => {
|
|
return (
|
|
plugin !== null &&
|
|
plugin !== undefined &&
|
|
typeof plugin === 'object' &&
|
|
'name' in plugin &&
|
|
typeof plugin.name === 'string'
|
|
)
|
|
}
|
|
)
|
|
// Business logic: filter out import-map plugins
|
|
.filter((plugin) => !plugin.name.includes('import-map'))
|
|
}
|
|
|
|
return mergeConfig(config, {
|
|
// Replace plugins entirely to avoid inheritance issues
|
|
plugins: [
|
|
// Only include plugins we explicitly need for Storybook
|
|
tailwindcss(),
|
|
Icons({
|
|
compiler: 'vue3',
|
|
customCollections: {
|
|
comfy: FileSystemIconLoader(
|
|
process.cwd() + '/packages/design-system/src/icons'
|
|
)
|
|
}
|
|
}),
|
|
Components({
|
|
dts: false, // Disable dts generation in Storybook
|
|
resolvers: [
|
|
IconsResolver({
|
|
customCollections: ['comfy']
|
|
})
|
|
],
|
|
dirs: [
|
|
process.cwd() + '/src/components',
|
|
process.cwd() + '/src/layout',
|
|
process.cwd() + '/src/views'
|
|
],
|
|
deep: true,
|
|
extensions: ['vue']
|
|
})
|
|
],
|
|
server: {
|
|
allowedHosts: true
|
|
},
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: '@/composables/queue/useJobList',
|
|
replacement: process.cwd() + '/src/storybook/mocks/useJobList.ts'
|
|
},
|
|
{
|
|
find: '@/composables/queue/useJobActions',
|
|
replacement: process.cwd() + '/src/storybook/mocks/useJobActions.ts'
|
|
},
|
|
{
|
|
find: '@/utils/formatUtil',
|
|
replacement:
|
|
process.cwd() +
|
|
'/packages/shared-frontend-utils/src/formatUtil.ts'
|
|
},
|
|
{
|
|
find: '@/utils/networkUtil',
|
|
replacement:
|
|
process.cwd() +
|
|
'/packages/shared-frontend-utils/src/networkUtil.ts'
|
|
},
|
|
{
|
|
find: '@',
|
|
replacement: process.cwd() + '/src'
|
|
}
|
|
]
|
|
},
|
|
esbuild: {
|
|
// Prevent minification of identifiers to preserve _sfc_main
|
|
minifyIdentifiers: false,
|
|
keepNames: true
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
// Disable tree-shaking for Storybook to prevent Vue SFC exports from being removed
|
|
treeshake: false,
|
|
onwarn: (warning, warn) => {
|
|
// Suppress specific warnings
|
|
if (
|
|
warning.code === 'UNUSED_EXTERNAL_IMPORT' &&
|
|
warning.message?.includes('resolveComponent')
|
|
) {
|
|
return
|
|
}
|
|
// Suppress Storybook font asset warnings
|
|
if (
|
|
warning.code === 'UNRESOLVED_IMPORT' &&
|
|
warning.message?.includes('nunito-sans')
|
|
) {
|
|
return
|
|
}
|
|
warn(warning)
|
|
}
|
|
},
|
|
chunkSizeWarningLimit: 1000
|
|
}
|
|
} satisfies InlineConfig)
|
|
}
|
|
}
|
|
export default config
|