Improve page load times and rendering

This commit is contained in:
adilallo
2026-05-26 06:59:52 -06:00
parent 6b45a2e5d0
commit 3be188a3cc
29 changed files with 467 additions and 176 deletions
+27
View File
@@ -13,6 +13,33 @@ export default defineConfig({
}
},
},
// Stub .svg imports as inert React components so SVGR-style imports
// (`import Foo from "./foo.svg"; <Foo />`) work without webpack/turbopack.
// `enforce: "pre"` so we run before Vite's default asset handler that would
// otherwise return the URL string.
{
name: "svg-mock",
enforce: "pre",
async resolveId(source, importer) {
if (!source.endsWith(".svg")) return null;
const resolved = await this.resolve(source, importer, {
skipSelf: true,
});
if (!resolved) return null;
return { ...resolved, id: `${resolved.id}?svg-mock` };
},
load(id) {
if (id.endsWith(".svg?svg-mock")) {
return `import * as React from "react";
const SvgMock = React.forwardRef(function SvgMock(props, ref) {
return React.createElement("svg", { ref, ...props });
});
export default SvgMock;
export const ReactComponent = SvgMock;
`;
}
},
},
],
esbuild: {
target: "node18",