-
-
Notifications
You must be signed in to change notification settings - Fork 10
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 chokes generated *.bib files in production build? #26
Comments
I believe this is a vite thing. Can you generate them inside of |
Sorry, I do not know how to to that... How should/would I reference this vite public dir? Currently I build these files via ---
pagination:
data: bibtex
size: 1
alias: bibtex
permalink: "publications/bibtex/{{ bibtex.bibtexLabel }}.bib"
layout: "layouts/bibtex.njk"
---
{{ bibtex.bibtexItem | safe }} I've found a promising vite config option: https://vitejs.dev/config/shared-options.html#assetsinclude eleventyConfig.addPlugin(EleventyVitePlugin, {
viteOptions: {
assetsInclude: ['**/*.bib'],
}
}); ...but this did not resolve my issue.... |
Perhaps related: ├── assets
│ ├── app.js
│ └── app.scss
├── downloads
│ └── myfile.pdf
├── eleventy.config.js
└── src
├── _includes
│ └── layout.njk
└── index.md // eleventy.config.js
const EleventyVitePlugin = require('@11ty/eleventy-plugin-vite')
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyVitePlugin);
eleventyConfig.addPassthroughCopy('assets');
eleventyConfig.addPassthroughCopy('downloads');
return {
dir: {
input: "src",
output: "_site"
},
}
} ❌ Build via
✅ ...but expected (and strangely I get the desired result with the # _site generated via `npx eleventy --serve`
_site/
├── assets
│ ├── app.js
│ ├── app.scss
│ ├── index.74d94aed.css
│ └── index.b2fff5ad.js
├── downloads
│ └── myfile.pdf
└── index.html Am I doing something completely wrong? Thanks in advance for any hints. I've put together a minimal eleventy project for this setup: https://github.com/tombreit/eleventy-vite-minimal/tree/vite-and-pdfs |
@tombreit So if you have a
and running
@zachleat Do mean generate them from So for instance I have a
that files is generated at I seem to be missing something here …? |
I had a similar problem with PDF files. I've managed to get it to work by having this folder structure
and then passthrough-copying public: eleventyConfig.addPassthroughCopy("public"); This then gives the output of:
The passthrough copying is necessary, it doesn't work if you just put public inside src. For things such as sitemaps and feeds, I was able to get them to work by leaving them in src with a permalink like |
Ran into the same problem, too; and while moving static assets into the ---
permalink: generated.json
value: true
---
{
"generated": {{ value }}
} While the I've tried This essentially means that Eleventy-generated pages of certain file extensions are mysteriously excluded/deleted from the final build by Vite; and it means that Vite's behaviour is significantly different between dev and prod. Neither seems acceptable default behaviour to me. Is there a workaround for this? |
The solution is mostly adding
During the prod build, vite only includes assets of specific types and tags referenced from your HTML. I'm working on extensive docs around this topic, which should clear this up in the future hopefully. |
Thanks! 👍 Adding Now we'd have to remember to add this segment to certain permalinks but not others. It also feels like a trap that it works either way on Is there any documentation (from Vite's side) as to which files Vite will nix and which it won't? Is there truly no configuration option in Vite to customise that behaviour? |
AFAIK With Vite 6 (stable plugin release is on v5!), this is the list of supported attributes: https://vite.dev/guide/features.html#html After all, I think if you chose to use Vite, you will want to apply their way of doing stuff. Otherwise a different asset pipeline might be better suited. |
Agreed that putting static assets to be copied into the But for Eleventy-generated files (such as the Thanks for the link, it's quite insightful! However, worth noting that not all generated files like this would or even could necessarily be loaded directly in HTML or JS (examples from our project: Let me know what you find in your research! Maybe it's a bug in Vite itself; or maybe it's something the |
I just ran into this bug too. The explanations in this issue are much appreciated. |
Hi,
I'm generating some
*.bib
-files from global datajs
viapagination
. When building vianpx eleventy --serve
everything works as expected: These*.bib
-files end up in the output directory (here:_site/publications/bibtex/*bib
).These
bib
-files are plaintext files with bibliographic data and are not meant to be further processed by vite:But in a production build via
npx eleventy
, it seems these*.bib
-files get rendered by eleventy, but somehow got choked/missed/deleted by vite afterwards...:via
npx eleventy --serve
via
npx eleventy
If I disable eleventy-plugin-vite or generate these files as
*.html
(instead of*.bib
) everything works as expected.What am I doing wrong or how do I keep my generated
.bib
files in a production build?Versions
The text was updated successfully, but these errors were encountered: