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

[vite-plugin] No path in vite manifest #845

Open
mmodler opened this issue Dec 15, 2024 · 1 comment
Open

[vite-plugin] No path in vite manifest #845

mmodler opened this issue Dec 15, 2024 · 1 comment

Comments

@mmodler
Copy link

mmodler commented Dec 15, 2024

Hey,

first thanks for your great work! I just tried responsive-image with vite 5 and 6 and noticed one issue:

If i glob import an image without responsive-image, its included in manifest.json like this:

  "resources/img/index/kontakt.jpg": {
    "file": "assets/kontakt-CA1xR13b.jpg",
    "src": "resources/img/index/kontakt.jpg"
  },
  "resources/js/app.js": {
    "file": "assets/app-BVk_b1N0.js",
    "name": "app",
    "src": "resources/js/app.js",
    "isEntry": true
  },

if u use responsive-image, its included without path:

  "_kontakt-1920w-Dk6CijxP.webp": {
    "file": "assets/kontakt-1920w-Dk6CijxP.webp",
    "src": "_kontakt-1920w-Dk6CijxP.webp"
  },
  "resources/js/app.js": {
    "file": "assets/app-BVk_b1N0.js",
    "name": "app",
    "src": "resources/js/app.js",
    "isEntry": true
  },

This causes inconsistent manifest.json paths. Is this a bug or if not, how can i fix it?

Thanks!

@mmodler mmodler changed the title No path in vite manifest [vite-plugin] No path in vite manifest Dec 15, 2024
@simonihmig
Copy link
Owner

I am not really familiar with how the manifest feature works, but I would assume this is not a bug rather it is expected.

The Vite plugin emits resized variants of the original image, but the original image itself is not used anymore for the build output. That's why I think it is expected that the manifest will not refer to the original file (resources/img/index/kontakt.jpg) anymore.

Two questions related to that...

  1. why do you need those images in the manifest? The images will be referred to in some of the JS chunks. There is no need to have anything in your index.html point to them directly. I assume the manifest is used to construct the HTML in some customized way, is that right?
  2. Have you enabled the vite plugin for all image imports? The docs recommend keeping default asset imports untouched, so the vite built-in asset handling continues to work for them, and have a query param like ?responsive to opt into the specials handling of this plugin where needed. That way if you want to get the URL of the original images, that would still work, and I think that should also keep those references in the manifest in place.

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

No branches or pull requests

2 participants