-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vite build static assets are inlined #461
Comments
oh, interesting. not sure i can think of a situation where you want assets to be referenced at all. there's not a lot you can do with an mp4 when you're SSR'ing HTML. Maybe we can work around it with |
I just stumbled upon this issue. All assets are inlined - images, fonts, etc. For example, I was trying to use a @fontsource package and the font files referenced by the css file in the package were all inlined into the generated css files. Images that are referenced from components are inlined in the respective javascript (and html in case of adapter-static) files. I'd very much like to explicitly import assets from js/css to benefit from hashed file names (infinitely cachable) and maybe other pipeline steps (e.g. image optimizations). |
The problem is actually not the assetsInlineLimit, but rather the fact the build.lib configuration option is set by Svelte Kit: kit/packages/kit/src/core/build/index.js Lines 122 to 129 in 17bb699
If that is set, assets are never exported as files. Without the lib option, the compiler runs into an issue with the dynamic import polyfill as mentioned in the comments. With just this line https://github.com/vitejs/vite/blob/5d4e82d90238b0d52ded1eea6359947eefc5e054/packages/vite/src/node/plugins/asset.ts#L201 |
I found that disabling lib mode and explicitly disabling the dynamic import polyfill gives practically identical results, but causes imported assets to be properly emitted. Pull request: #741 |
closed via #741 |
I'm getting this same issue when deploying to Netlify. I have a link to download a ".pub" file in assets, ".pub" was added to vite.assetsInclude, but I just get a base64 inline thing. I imported the asset with Interestingly enough, this doesn't happen with my ".gpg" files or any other asset, and I imported them in the same exact way. |
Describe the bug
Because of how svelte kit is passing the entry file as
lib:
in vite buildkit/packages/kit/src/core/build/index.js
Lines 58 to 62 in 5416bd7
all static files, ie:
*.png
,*.mp4
are inlined in the build, due to this logic in vite:https://github.com/vitejs/vite/blob/5d4e82d90238b0d52ded1eea6359947eefc5e054/packages/vite/src/node/plugins/asset.ts#L200-L207
Expected behavior
Honour
assetsInlineLimit
invite.config.js
and emit as a separate assets if it exceeds the inline limit.I can understand why vite is implemented that way, at the same time, I'm not sure what other apis / ways we could do on svelte kit side alone. I believe this requires changes on both sides
The text was updated successfully, but these errors were encountered: