Open darekkay opened 1 year ago
The issue is caused by the "draft" feature, or more specifically, when renderFile
is used within a file that is excluded from collections (eleventyComputedExcludeFromCollections
). That's why eleventy --serve
works (drafts are not excluded) and eleventy
doesn't (drafts excluded). Adding renderFile
to a non-draft post in the eleventy-base-blog repository doesn't cause the issue.
A workaround is to add a guard to eleventy-plugin-bundle to check if this.page
is defined. However, I feel like the proper solution should be to skip eleventy-plugin-bundle
(and eleventy-plugin-webc
) completely for excluded files, also from performance perspective.
I've had a workaround to delete draft posts on CI before building 11ty, but for unrelated reasons this workaround is no longer viable for me.
As already mentioned, a quick fix would be to check in eleventy-plugin-bundle
if this.page
is defined before trying to access this.page.url
. However, the issue begins already in eleventy-plugin-webc
: if the page should not be rendered (permalink: false
), there's no point in extracting the bundles.
I've created a pull request with a fix: #93
Running
eleventy
fails when including a WebC file withrenderFile
in a file that is excluded from collections.I have reproduced the issue within eleventy-base-blog by applying the following commit:
https://github.com/darekkay/eleventy-base-blog/commit/f60f8814db8689e4a0f23e9a6d2d9ca99a8b7239
As the demo displays, the issue occurs when including a
webc
file usingrenderFile
:It works fine when running
npm run start
(i.e. the dev server), by opening fifthpost:But it fails with
npm run build
:The issue is "fixed" when the
renderFile
line is removed.The issue does not happen when including a markdown file (as presented in the same demo).
Reproducible on: