gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.95k stars 7.47k forks source link

Skip server rebuilds for change sets that don't resolve to any file mount #12861

Open jmooring opened 1 week ago

jmooring commented 1 week ago

I'm not sure if this is a bug or an enhancement... or perhaps there's a good reason for the current behavior.

[[module.mounts]]
source = 'content'
target = 'content'
excludeFiles = ['posts/*']

With the above, when I edit content/posts/post-1.md ...

DEBUG Received System Events: [WRITE         "/home/jmooring/code/hugo-testing/content/posts/post-1.md" WRITE         "/home/jmooring/code/hugo-testing/content/posts/post-1.md"]

Change detected, rebuilding site (#5).
2024-09-19 10:43:59.783 -0700
DEBUG cachebuster: Matching "content/posts/post-1.md" with source "(postcss|tailwind)\\.config\\.js": no match
Source changed /posts/post-1.md
DEBUG 
INFO  build:  step process substep resolve page output change set changes 0 checked 0 matches 0 duration 104.933µs
INFO  build:  step process substep gc dynacache duration 338.639µs
INFO  build:  step process substep collect files 0 files_total 0 pages_total 0 resources_total 0 duration 460.679µs
INFO  build:  step process duration 1.727645ms
INFO  build:  step assemble duration 314.482µs
INFO  build:  step render substep pages site en outputFormat html duration 95.511µs
INFO  build:  step render substep pages site en outputFormat rss duration 92.611µs
INFO  build:  step render pages 0 content 0 duration 449.541µs
INFO  build:  step render deferred count 0 duration 4.045µs
INFO  build:  step postProcess duration 16.526µs
INFO  build:  duration 3.17658ms
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Total in 3 ms
INFO  livereload: build changed 0 files

I can see from the last line that no files have changed, which is good, but it seems like we shouldn't be doing the other stuff.

Tested with hugo v0.135.0-DEV-a619deec1827ea2d601a9b3708d1375c1eca3c5c+extended linux/amd64

jmooring commented 1 week ago

Note that using the ignoreFiles setting in the root of the site configuration produces the desired results, but we've been recommending the use of mount exclusions instead.

bep commented 1 week ago

The issue title here isn't correct. We do honor mount ignore files setting for all builds, meaning: We don't build them. We trigger a noop build when those files changes, which I guess is a difference between the global setting, but I would say that that is undocumented behaviour. We could and should probably skip builds for change sets that don't resolve to any files on the file system.

Note that using the ignoreFiles setting in the root of the site configuration produces the desired results

ignoreFiles only works for content files, which isn't my desired result.

jmooring commented 1 week ago

Thanks for the clarification. This obviously isn't a high priority.