LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
[FIX] Handle missing plugin asset imports in Vite build (#1818)
vishnuszipstack1cad9b7f70aa
diff --git a/frontend/vite.config.js b/frontend/vite.config.jsindex 40a66809d..21cc81fb0 100644--- a/frontend/vite.config.js+++ b/frontend/vite.config.js@@ -5,12 +5,29 @@ import { defineConfig, loadEnv } from "vite";import svgr from "vite-plugin-svgr";const EMPTY_MODULE_ID = "\0optional-plugin-empty";+const EMPTY_ASSET_MODULE_ID = "\0optional-plugin-empty-asset";++const ASSET_EXTENSIONS = new Set([+ ".svg",+ ".png",+ ".jpg",+ ".jpeg",+ ".gif",+ ".webp",+ ".ico",+ ".bmp",+ ".tiff",+]);// Rollup plugin that resolves missing optional plugin imports to an empty// module instead of failing the build. This lets the existing// `try { await import("./plugins/...") } catch {}` pattern work at build// time: Rollup will bundle an empty module for any plugin path that does// not exist on disk, and the catch block handles the rest at runtime.+//+// Asset imports (images, SVGs, etc.) are resolved to a module that exports+// an empty string as default, so static `import logo from "..."` statements+// don't break the build.function optionalPluginImports() {return {name: "optional-plugin-imports",@@ -20,7 +37,10 @@ function optionalPluginImports() {// Only handle relative importsif (!source.startsWith(".")) return null;- const resolved = path.resolve(path.dirname(importer), source);+ // Strip query strings and hashes (e.g. "./logo.svg?react" → "./logo.svg")+ // so path.extname and fs.existsSync work correctly.+ const sourcePath = source.split("?")[0].split("#")[0];+ const resolved = path.resolve(path.dirname(importer), sourcePath);// Only handle imports that resolve within a plugins directory.// This covers both cross-plugin imports (e.g. "../plugins/foo")@@ -37,6 +57,11 @@ function optionalPluginImports() {);if (!exists) {+ // Asset files need a default export so static imports work.+ const ext = path.extname(sourcePath).toLowerCase();+ if (ASSET_EXTENSIONS.has(ext)) {+ return EMPTY_ASSET_MODULE_ID;+ }return EMPTY_MODULE_ID;}@@ -46,6 +71,9 @@ function optionalPluginImports() {if (id === EMPTY_MODULE_ID) {return "throw new Error('Optional plugin not available');";}+ if (id === EMPTY_ASSET_MODULE_ID) {+ return "export default '';";+ }return null;},};