mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Lint/format vite.config.mts (#2103)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
'./**/*.js': (stagedFiles) => formatAndEslint(stagedFiles),
|
||||
|
||||
'./**/*.{ts,tsx,vue}': (stagedFiles) => [
|
||||
'./**/*.{ts,tsx,vue,mts}': (stagedFiles) => [
|
||||
...formatAndEslint(stagedFiles),
|
||||
'vue-tsc --noEmit',
|
||||
'tsc --noEmit',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineConfig, Plugin } from 'vite'
|
||||
import type { UserConfigExport } from 'vitest/config'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
import dotenv from "dotenv"
|
||||
import dotenv from 'dotenv'
|
||||
import Icons from 'unplugin-icons/vite'
|
||||
import IconsResolver from 'unplugin-icons/resolver'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
@@ -20,9 +20,9 @@ interface ShimResult {
|
||||
}
|
||||
|
||||
function isLegacyFile(id: string): boolean {
|
||||
return id.endsWith('.ts') && (
|
||||
id.includes("src/extensions/core") ||
|
||||
id.includes("src/scripts")
|
||||
return (
|
||||
id.endsWith('.ts') &&
|
||||
(id.includes('src/extensions/core') || id.includes('src/scripts'))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,15 +43,15 @@ function comfyAPIPlugin(): Plugin {
|
||||
const shimComment = `// Shim for ${relativePath}\n`
|
||||
|
||||
this.emitFile({
|
||||
type: "asset",
|
||||
type: 'asset',
|
||||
fileName: shimFileName,
|
||||
source: shimComment + result.exports.join("")
|
||||
source: shimComment + result.exports.join('')
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
code: result.code,
|
||||
map: null // If you're not modifying the source map, return null
|
||||
map: null // If you're not modifying the source map, return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,8 @@ function transformExports(code: string, id: string): ShimResult {
|
||||
let newCode = code
|
||||
|
||||
// Regex to match different types of exports
|
||||
const regex = /export\s+(const|let|var|function|class|async function)\s+([a-zA-Z$_][a-zA-Z\d$_]*)(\s|\()/g
|
||||
const regex =
|
||||
/export\s+(const|let|var|function|class|async function)\s+([a-zA-Z$_][a-zA-Z\d$_]*)(\s|\()/g
|
||||
let match
|
||||
|
||||
while ((match = regex.exec(code)) !== null) {
|
||||
@@ -75,7 +76,9 @@ function transformExports(code: string, id: string): ShimResult {
|
||||
newCode += `\nwindow.comfyAPI.${moduleName} = window.comfyAPI.${moduleName} || {};`
|
||||
}
|
||||
newCode += `\nwindow.comfyAPI.${moduleName}.${name} = ${name};`
|
||||
exports.push(`export const ${name} = window.comfyAPI.${moduleName}.${name};\n`)
|
||||
exports.push(
|
||||
`export const ${name} = window.comfyAPI.${moduleName}.${name};\n`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -88,10 +91,11 @@ function getModuleName(id: string): string {
|
||||
// Simple example to derive a module name from the file path
|
||||
const parts = id.split('/')
|
||||
const fileName = parts[parts.length - 1]
|
||||
return fileName.replace(/\.\w+$/, '') // Remove file extension
|
||||
return fileName.replace(/\.\w+$/, '') // Remove file extension
|
||||
}
|
||||
|
||||
const DEV_SERVER_COMFYUI_URL = process.env.DEV_SERVER_COMFYUI_URL || 'http://127.0.0.1:8188'
|
||||
const DEV_SERVER_COMFYUI_URL =
|
||||
process.env.DEV_SERVER_COMFYUI_URL || 'http://127.0.0.1:8188'
|
||||
|
||||
export default defineConfig({
|
||||
base: '',
|
||||
@@ -99,7 +103,7 @@ export default defineConfig({
|
||||
host: VITE_REMOTE_DEV ? '0.0.0.0' : undefined,
|
||||
proxy: {
|
||||
'/internal': {
|
||||
target: DEV_SERVER_COMFYUI_URL,
|
||||
target: DEV_SERVER_COMFYUI_URL
|
||||
},
|
||||
|
||||
'/api': {
|
||||
@@ -111,7 +115,7 @@ export default defineConfig({
|
||||
res.end(JSON.stringify([]))
|
||||
}
|
||||
return null
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
'/ws': {
|
||||
@@ -135,7 +139,7 @@ export default defineConfig({
|
||||
comfyAPIPlugin(),
|
||||
|
||||
Icons({
|
||||
'compiler': 'vue3'
|
||||
compiler: 'vue3'
|
||||
}),
|
||||
|
||||
Components({
|
||||
@@ -172,7 +176,9 @@ export default defineConfig({
|
||||
},
|
||||
|
||||
define: {
|
||||
'__COMFYUI_FRONTEND_VERSION__': JSON.stringify(process.env.npm_package_version)
|
||||
__COMFYUI_FRONTEND_VERSION__: JSON.stringify(
|
||||
process.env.npm_package_version
|
||||
)
|
||||
},
|
||||
|
||||
resolve: {
|
||||
@@ -182,9 +188,6 @@ export default defineConfig({
|
||||
},
|
||||
|
||||
optimizeDeps: {
|
||||
exclude: [
|
||||
'@comfyorg/litegraph',
|
||||
'@comfyorg/comfyui-electron-types'
|
||||
]
|
||||
exclude: ['@comfyorg/litegraph', '@comfyorg/comfyui-electron-types']
|
||||
}
|
||||
}) as UserConfigExport
|
||||
}) as UserConfigExport
|
||||
|
||||
Reference in New Issue
Block a user