mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
Fix cache busting setup
By correctly capturing the target variable when compiling the cache buster. Fixes #11268
This commit is contained in:
@@ -164,3 +164,36 @@ func TestBuildConfigCacheBusters(t *testing.T) {
|
||||
c.Assert(m("json"), qt.IsTrue)
|
||||
|
||||
}
|
||||
|
||||
func TestBuildConfigCacheBusterstTailwindSetup(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
cfg := New()
|
||||
cfg.Set("build", map[string]interface{}{
|
||||
"cacheBusters": []map[string]string{
|
||||
{
|
||||
"source": "assets/watching/hugo_stats\\.json",
|
||||
"target": "css",
|
||||
},
|
||||
{
|
||||
"source": "(postcss|tailwind)\\.config\\.js",
|
||||
"target": "css",
|
||||
},
|
||||
{
|
||||
"source": "assets/.*\\.(js|ts|jsx|tsx)",
|
||||
"target": "js",
|
||||
},
|
||||
{
|
||||
"source": "assets/.*\\.(.*)$",
|
||||
"target": "$1",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
conf := DecodeBuildConfig(cfg)
|
||||
l := loggers.NewDefault()
|
||||
c.Assert(conf.CompileConfig(l), qt.IsNil)
|
||||
|
||||
m, err := conf.MatchCacheBuster(l, "assets/watching/hugo_stats.json")
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(m("css"), qt.IsTrue)
|
||||
}
|
||||
|
Reference in New Issue
Block a user