From bfd99ecb6da5060a9a09d0c78eafb444b105e14c Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Wed, 2 Oct 2024 14:55:14 -0700 Subject: [PATCH] Fix: prevent bundling demo XForm XML fixtures as inline `data:` URLs This ensures that XForm fixtures loaded by URL are always reachable with the current access mechanism. --- packages/web-forms/vite.config.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/web-forms/vite.config.ts b/packages/web-forms/vite.config.ts index e0cf847b8..36de781f9 100644 --- a/packages/web-forms/vite.config.ts +++ b/packages/web-forms/vite.config.ts @@ -116,6 +116,26 @@ export default defineConfig(({ mode }) => { }, build: { target: 'esnext', + /** + * Prevent bundling XForm fixture assets as inlined `data:` URLs. + * + * Per Vite's documentation, returning `false` opts out of inlining for + * assets with a `.xml` extension; for all other assets, we do not return + * a value, deferring to Vite's default behavior. We'll generally want the + * default behavior, but this comment should serve as a breadcrumb if we + * need to reconsider that assumption. + * + * @see + * {@link https://vite.dev/config/build-options.html#build-assetsinlinelimit} + */ + assetsInlineLimit: (filePath) => { + // Prevent inlining XML form fixture assets as `data:` URLs. + if (filePath.endsWith('.xml')) { + return false; + } + + // Per Vite docs + }, lib, rollupOptions: { external,