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 clearing addPassthroughCopy files on production? #42

Open
bronze opened this issue Sep 16, 2023 · 3 comments
Open

Vite clearing addPassthroughCopy files on production? #42

bronze opened this issue Sep 16, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@bronze
Copy link

bronze commented Sep 16, 2023

Hi

I've been cracking my head on this one and would appreciate another view.
I have eleventyConfig.addPassthroughCopy('src/assets/images') set up because i want to use the images on my og:image tags.

However, when building for production, all my images vanish around the time we hit his part

vite v4.4.9 building for production...
transforming...
 282 modules transformed.
rendering chunks...
computing gzip size...

I've tried changing the name of the folder because I thought maybe it may have something to do with using the assets folder, but no deal.
Tried passing emptyOutDir: false, on viteOptions but also didn't solve.

Anyone else encountered this?

Thanks

@lukarenko
Copy link

lukarenko commented Oct 15, 2023

I have similar problem with og:image: images are copied to destination folder, but they get -<hashcode> appended to image file name in order to improve caching issues for production site.

I have checked Vite code and it seems that they should prpoprly process <meta> tags with og:image property, however they do not do this on my project.

I have also submitted but to vite with more information:
vitejs/vite#14627

@restyler
Copy link

restyler commented Nov 14, 2023

Shoot. I have just spent two straight days debugging the exact same issue and thinking I am going crazy.
The awful part of the bug is that it was not possible to debug it using DEBUG env set for npm run build. I saw my
addPassthroughCopy image files copied over to my dist folder - and then, when I examined my dist folder - copied files were not there. My eleventy config file was big so it was a huge pain to investigate this, by commenting out things one by one.
Vite silently removes my copied files!

@aaronstezycki
Copy link

Having used the Slinkity plugin, I've come across this issue. Vite in general only processes assets that is needs, removing any files that aren't directly resolved through html files.

Eleventy will build into a temp folder first, and then Vite plugin looks at that folder to process the final build. Passthrough copy, will copy files to the temp folder, and then Vite processes what it needs from there, and removes the rest. Chances are Vite is not considering these files for final build.

Best bet is use the 'public' folder top level of the project. Get eleventy to passthrough copy that public folder and Vite will then process that folder to the final build. Only downside to that is these files won't be hashed, they just get copied from one directly to another.

--public
  |- meta
    |- og-image.png 
-- src
  |- project files

becomes the following for final build.

--/dist
  |- meta
    |- og-image.png 
  --index
  --etc

There's a little more about it on the Slinkity docs: stripped assets

@KiwiKilian KiwiKilian added the documentation Improvements or additions to documentation label Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants