You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a simple plugin which transforms an image into multiple different sizes and creates a virtual file with mapping of {size: "url"}. The URLs are created with pluginContext.emitFile({"type": "asset", ...}) and the resulting reference is placed in import.meta.ROLLUP_FILE_URL_${ref} as per docs. It works perfectly when building with Rollup, but with Vite (no matter if I use the plugin in build.rollupOptions or in Vite plugins directly), broken code is generated.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
I realized that this can be solved by using __VITE_ASSET__${ref}__ instead during the Vite build - see mvolfik/symmetrical-train@fb06e46. This should be noted somewhere in docs (just spent half a day debugging this oops), and I'm curious what's the reason for this, what counterweights making some Rollup plugins incompatible with Vite?
Describe the bug
I created a simple plugin which transforms an image into multiple different sizes and creates a virtual file with mapping of
{size: "url"}
. The URLs are created withpluginContext.emitFile({"type": "asset", ...})
and the resulting reference is placed inimport.meta.ROLLUP_FILE_URL_${ref}
as per docs. It works perfectly when building with Rollup, but with Vite (no matter if I use the plugin in build.rollupOptions or in Vite plugins directly), broken code is generated.Code generated by the plugin:
Rollup output
Vite output
Reproduction
Repo: https://github.com/mvolfik/symmetrical-train/tree/46722dec52f64b7c8501a2789d33f527e1fea87f
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: