mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Create hugo_stats.json if it's mounted but does not exists
A common pattern for Tailwind 3 is to mount that file to get it on the server watch list. A common pattern is also to add hugo_stats.json to .gitignore. This has meant that the first time you start the server (no hugo_stats.json), it just doesn't work as expected. Fixes #11264
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/bep/logg"
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/publisher"
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
@@ -491,14 +492,12 @@ func (h *HugoSites) writeBuildStats() error {
|
||||
HTMLElements: *htmlElements,
|
||||
}
|
||||
|
||||
const hugoStatsName = "hugo_stats.json"
|
||||
|
||||
js, err := json.MarshalIndent(stats, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filename := filepath.Join(h.Configs.LoadingInfo.BaseConfig.WorkingDir, hugoStatsName)
|
||||
filename := filepath.Join(h.Configs.LoadingInfo.BaseConfig.WorkingDir, files.FilenameHugoStatsJSON)
|
||||
|
||||
if existingContent, err := afero.ReadFile(hugofs.Os, filename); err == nil {
|
||||
// Check if the content has changed.
|
||||
|
Reference in New Issue
Block a user