Skip to content
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

Assets should be emitted in SSR mode #11429

Closed
7 tasks done
Rich-Harris opened this issue Dec 19, 2022 · 0 comments · Fixed by #11430
Closed
7 tasks done

Assets should be emitted in SSR mode #11429

Rich-Harris opened this issue Dec 19, 2022 · 0 comments · Fixed by #11430

Comments

@Rich-Harris
Copy link
Contributor

Describe the bug

If my client-side JavaScript imports an image...

import potato from './potato.jpg';

...then at build time the asset is hashed, the import is replaced with const potato = '/assets/potato-xyz123.jpg', and the file is written out to that directory.

This does not happen for an ssr build. The import replacement happens, but no potato-xyz123.jpg file is written. Since it's often the case that some code is part of the server build but not part of the client build, this results in missing assets, causing bugs like sveltejs/kit#5240.

Reproduction

https://github.com/Rich-Harris/vite-ssr-assets

Steps to reproduce

git clone git@github.com:Rich-Harris/vite-ssr-assets
cd vite-ssr-assets
npm install
npm run build

System Info

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 74.03 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  Browsers:
    Chrome: 108.0.5359.124
    Chrome Canary: 111.0.5486.0
    Firefox: 108.0
    Safari: 15.6.1
  npmPackages:
    vite: ^4.0.2 => 4.0.2

Used Package Manager

npm

Logs

No response

Validations

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants