-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Vue + Vite + SSR: Referencing public assets with the root path (/myimage.jpg
) inside the public
directory results in a Rollup error
#10082
Comments
Vite-plugin-ssr doesn't do anything with |
It seems it does not reproduce with a simple setup. And it happens with vite-plugin-ssr + react too. |
Only because you imported the images, not used them with the root path as The same doesn't work with Vue though. |
plugin-vue transforms <template>
<img :src="logoSvg" />
</template>
<script setup>
import logoSvg from '/logo.svg'
</script> So something is not working around resolving |
It builds successfully with the following import vue from "@vitejs/plugin-vue";
import ssr from "vite-plugin-ssr/plugin";
import { UserConfig } from "vite";
const config: UserConfig = {
plugins: [
vue({
template: {
transformAssetUrls: {
img: [],
},
},
}),
ssr({ prerender: true }),
],
};
export default config; https://stackblitz.com/edit/vitejs-vite-nsfvwb?file=vite.config.ts So it is indeed the Vue plugin that causes this. I'm just checking the documentation: https:/vitejs/vite/tree/main/packages/plugin-vue#asset-url-handling This behaviour was introduced in |
It seems that Vite-plugin-ssr 0.4 changed Vite's config I reverted that change and released a new version @truumahn Let me know if you run into any other issues. We can close this in the meantime. @sapphi-red The proper fix would be to stop separating the client-side and server-side building process into two isolated processes. FYI, this is one of many reasons why I believe the decision the Vite team took here #9496 (comment) was a mistake. Separating both builds is asking for trouble. |
I created a discussion #10097 - Unify client-side and server-side build steps about this. |
Yes. This is because of #10082 (comment).
What is the purpose of changing this? Avoiding the public directory to be copied? I think it's correct not to resolve public assets when |
Yes, to avoid the public directory being copied twice at |
I'm closing this as the original issue has been resolved. The discussion can be continued in #10097 |
Describe the bug
Using vite-plugin-ssr with Vue, running
build
with an asset referenced from the root path (e.g./myimage.jpg
) results in a Rollup error. This doesn't occur duringdev
.Also, the issue doesn't occur when used with a generic Vue SPA.
However, @brillout noted that vite-plugin-ssr doesn't do anything about the public directory
Here's a detailed explanation of the scenarios:
Scenario A: VPS with Vue using
npm init vite-plugin-ssr@latest
myimage.jpg
can be found inpublic
directory, inside the root component in the template:this breaks:
this works:
Scenario B: Vue 3 project using
npm init vue@latest
myimage.jpg
can be found inpublic
directory, inside the root component in the template:this works:
this works:
Reproduction
https:/truumahn/vps-public-image-repro
System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: