Skip to content

Fix: remove file path matching for dev nunjucks watcher #1620

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tjk911
Copy link

@tjk911 tjk911 commented May 13, 2025

When we make changes to the _layouts folder, the nunjucks watch function sees it but does not rebuild associated pages.

Issue example:

  1. Make change to _layouts/header.html
  2. Check localhost:3000
  3. Nothing changes

We noticed it would work if we:

  1. Make change to _layouts/header.html
  2. Save index.html
  3. Check localhost:3000
  4. See changes

With help from @brandonrobertz, we tracked it down to the lib/engines/nunjucks.js file.

We suspect that

    if (file !== path)
        continue;

was ignoring layouts changes because it would see that _layouts/header.html != index.html and ignore it. Removing this seemed to have fixed this issue.

@brandonrobertz
Copy link
Contributor

Some context: when I wrote this onChange handler, I cobbled code together from other places and wasn't 100% sure if this file !== path check was important or not. So I included it just in case. I think it's probably safe to remove it and rebuild all the files whenever we notice a change. This actually explains some odd behavior I've seen in the past (no show stoppers just annoyances) and this PR should fix those.

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

Successfully merging this pull request may close these issues.

2 participants