]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl/css: Add a test case for rebuilds on CSS options changes
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 15 Mar 2026 10:04:07 +0000 (11:04 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 15 Mar 2026 10:09:02 +0000 (11:09 +0100)
tpl/css/build_integration_test.go

index dd674d63d5a4af375ac4e337f94474ad39ccb3dd..f3bf8117a8f590596bd0f3ebf344fdf324110dde 100644 (file)
@@ -141,6 +141,34 @@ All. No CSS here.
        b.AssertFileContent("public/css/main.css", `.main{background:#00f}`) // updated content, blue gets minified to #00f.
 }
 
+func TestCSSBuildEditOptions(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ["taxonomy", "term", "rss"]
+disableLiveReload = true
+-- assets/css/main.css --
+body {
+ background: red;
+}
+-- layouts/home.html --
+Home.
+{{ with resources.Get "css/main.css"  }}
+{{ $opts := dict "minify" false }}
+{{ with . | css.Build $opts  }}
+ <link rel="stylesheet" href="{{ .RelPermalink }}" />
+{{ end }}
+{{ end }}
+`
+
+       b := hugolib.TestRunning(t, files, hugolib.TestOptOsFs())
+       b.AssertFileContent("public/css/main.css", `  background: red;`)
+
+       b.EditFileReplaceAll("layouts/home.html", `"minify" false`, `"minify" true`).Build()
+       b.AssertFileContent("public/css/main.css", `{background:red}`)
+}
+
 func TestCSSBuildSourceMaps(t *testing.T) {
        t.Parallel()