From 2548ef110fd3ca23859c923d2c61393a732a7239 Mon Sep 17 00:00:00 2001 From: Peyton-Spencer Date: Tue, 24 Feb 2026 14:30:15 -0500 Subject: [PATCH 1/2] Skip plugin entirely in production builds via apply: "serve" The plugin was consuming 90% of build time during `vite build` because Rolldown called into the transform hook for every module, even though it returned null immediately. Using Vite's `apply: "serve"` option removes the plugin entirely from the build pipeline in production, eliminating all hook call overhead. Co-Authored-By: Claude Opus 4.6 --- src/vite.ts | 8 ++------ tests/vite-plugin.test.ts | 18 ++++++++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/vite.ts b/src/vite.ts index ce83372..77d9eb6 100644 --- a/src/vite.ts +++ b/src/vite.ts @@ -184,15 +184,14 @@ export default function solidGrab( } = options; let projectRoot = ""; - let isDev = false; return { name: "solid-grab", enforce: "pre", // Run before vite-plugin-solid + apply: "serve", // Only active during dev — completely skipped in production builds configResolved(config: ResolvedConfig) { projectRoot = config.root; - isDev = config.command === "serve" || config.mode === "development"; }, // Virtual module that imports the runtime — resolved by Vite's pipeline @@ -207,9 +206,6 @@ export default function solidGrab( }, transform(code, id) { - // Only transform in dev mode - if (!isDev) return null; - // Only transform JSX/TSX files in the user's project if (!/\.[jt]sx$/.test(id)) return null; if (id.includes("node_modules")) return null; @@ -245,7 +241,7 @@ export default function solidGrab( // Inject a