mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
## Summary Extracts desktop UI into apps/desktop-ui package with minimal changes. ## Changes - **What**: - Separates desktop-specific code into standalone package with independent Vite config, router, and i18n - Drastically simplifies the main app router by removing all desktop routes - Adds a some code duplication, most due to the existing design - Some duplication can be refactored to be *simpler* on either side - no need to split things by `isElectron()` - Rudimentary storybook support has been added - **Breaking**: Stacked PR for publishing must be merged before this PR makes it to stable core (but publishing _could_ be done manually) - #5915 - **Dependencies**: Takes full advantage of pnpm catalog. No additional dependencies added. ## Review Focus - Should be no changes to normal frontend operation - Scripts added to root package.json are acceptable - The duplication in this PR is copied as is, wherever possible. Any corrections or fix-ups beyond the scope of simply migrating the functionality as-is, can be addressed in later PRs. That said, if any changes are made, it instantly becomes more difficult to separate the duplicated code out into a shared utility. - Tracking issue to address concerns: #5925 ### i18n Fixing i18n is out of scope for this PR. It is a larger task that we should consider carefully and implement properly. Attempting to isolate the desktop i18n and duplicate the _current_ localisation scripts would be wasted energy.
103 lines
3.1 KiB
TypeScript
103 lines
3.1 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'],
|
|
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']
|
|
})
|
|
// Note: Explicitly NOT including generateImportMapPlugin to avoid externalization
|
|
],
|
|
server: {
|
|
allowedHosts: true
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': process.cwd() + '/src'
|
|
}
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
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
|