Files
ComfyUI_frontend/vite.electron.config.mts
snomiao 8bfb1009ce [style] migrate to @prettier/plugin-oxc for faster formatting
Replace @trivago/prettier-plugin-sort-imports with @prettier/plugin-oxc
and @ianvs/prettier-plugin-sort-imports for improved performance.

Changes:
- Add @prettier/plugin-oxc (Rust-based fast parser)
- Add @ianvs/prettier-plugin-sort-imports (import sorting compatible with oxc)
- Remove @trivago/prettier-plugin-sort-imports
- Update .prettierrc to use new plugins and compatible import order config
- Reformat all files with new plugin configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 00:02:04 +00:00

89 lines
2.8 KiB
TypeScript

import { defineConfig, mergeConfig, type Plugin } from 'vite'
import baseConfig from './vite.config.mts'
const mockElectronAPI: Plugin = {
name: 'mock-electron-api',
transformIndexHtml() {
return [
{
tag: 'script',
children: `window.electronAPI = {
restartApp: () => {
alert('restartApp')
},
sendReady: () => {},
onShowSelectDirectory: () => {},
onFirstTimeSetupComplete: () => {},
onProgressUpdate: () => {},
onLogMessage: () => {},
isFirstTimeSetup: () => Promise.resolve(true),
getSystemPaths: () =>
Promise.resolve({
appData: 'C:/Users/username/AppData/Roaming',
appPath: 'C:/Program Files/comfyui-electron/resources/app',
defaultInstallPath: 'bad'
}),
validateInstallPath: (path) => {
if (path === 'bad') {
return { isValid: false, error: 'Bad path!' }
}
return { isValid: true }
},
migrationItems: () =>
Promise.resolve([
{
id: 'user_files',
label: 'User Files',
description: 'Settings and user-created workflows'
}
]),
validateComfyUISource: (path) => {
if (path === 'bad') {
return { isValid: false, error: 'Bad path!' }
}
return { isValid: true }
},
showDirectoryPicker: () => Promise.resolve('C:/Users/username/comfyui-electron/1'),
DownloadManager: {
getAllDownloads: () => Promise.resolve([]),
onDownloadProgress: () => {}
},
getElectronVersion: () => Promise.resolve('1.0.0'),
getComfyUIVersion: () => '9.9.9',
getPlatform: () => 'win32',
changeTheme: () => {},
Config: {
setWindowStyle: () => {},
getWindowStyle: () => Promise.resolve('default'),
getDetectedGpu: () => Promise.resolve('nvidia')
},
Events: {
trackEvent: (event_name, event_data) => {
console.log('trackEvent', event_name, event_data)
},
incrementUserProperty: (property, value) => {
console.log('incrementUserProperty', property, value)
}
},
NetWork: {
canAccessUrl: (url) => {
const canAccess = url.includes('good')
console.log('canAccessUrl', url, canAccess)
return new Promise((resolve) => setTimeout(() => resolve(canAccess), 10000))
}
},
setMetricsConsent: (consent) => {}
};`
}
]
}
}
export default mergeConfig(
baseConfig,
defineConfig({
plugins: [mockElectronAPI]
})
)