Skip to content

Commit 2b4cbd4

Browse files
authored
Replace .eleventyignore with addPreprocessor calls; fix file watching (#4609)
I only just noticed this week that apparently the change to `.eleventyignore` in #4535 somehow caused a regression in the Eleventy dev server's behavior, where many (but not all) files would no longer trigger hot-reloading. This wouldn't be the first time I've observed odd behavior with `.eleventyignore`, and I had also since read about [`addPreprocessor`](https://www.11ty.dev/docs/config-preprocessors/) added in Eleventy v3 which would enable equivalent behavior with less-exhaustive definitions, so I decided to go about replacing one with the other. However, that still somehow wasn't enough to resolve the broken watch behavior. It's possible the previous `.eleventyignore` rule had somehow been masking this and it's more related to our usage of `addPassthroughCopy`. I've added explicit `addWatchTarget` calls which seems to work around it. This PR does not cause any changes to build output.
1 parent 9ab7c93 commit 2b4cbd4

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

.eleventyignore

Lines changed: 0 additions & 29 deletions
This file was deleted.

eleventy.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,28 @@ export default async function (eleventyConfig: any) {
166166
isUnderstanding ? flatGuidelines[resolveUnderstandingFileSlug(page.fileSlug)] : null,
167167
});
168168

169+
const ignoredEndings = [
170+
"-template.html",
171+
"understanding/20/accessibility-support-documenting.html",
172+
"understanding/20/seizures.html",
173+
];
174+
eleventyConfig.addPreprocessor("ignore-html", "html", ({ page }: GlobalData) => {
175+
if (
176+
!page.filePathStem.startsWith("/errata/") &&
177+
!page.filePathStem.startsWith("/techniques/") &&
178+
!page.filePathStem.startsWith("/understanding/") &&
179+
page.filePathStem !== "/index"
180+
)
181+
return false;
182+
if (page.inputPath.includes("/img/")) return false;
183+
for (const ending of ignoredEndings) if (page.inputPath.endsWith(ending)) return false;
184+
});
185+
eleventyConfig.addPreprocessor("ignore-md", "md", () => false);
186+
187+
// Add explicit watch targets to avoid addPassthroughCopy interference
188+
eleventyConfig.addWatchTarget("techniques/**");
189+
eleventyConfig.addWatchTarget("understanding/**");
190+
169191
eleventyConfig.addPassthroughCopy("techniques/*.css");
170192
eleventyConfig.addPassthroughCopy("techniques/*/img/*");
171193
eleventyConfig.addPassthroughCopy({

0 commit comments

Comments
 (0)