summaryrefslogtreecommitdiffstats
path: root/resources/resource_transformers/tocss/scss/scss_integration_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'resources/resource_transformers/tocss/scss/scss_integration_test.go')
-rw-r--r--resources/resource_transformers/tocss/scss/scss_integration_test.go61
1 files changed, 60 insertions, 1 deletions
diff --git a/resources/resource_transformers/tocss/scss/scss_integration_test.go b/resources/resource_transformers/tocss/scss/scss_integration_test.go
index 02e2b9200..469463872 100644
--- a/resources/resource_transformers/tocss/scss/scss_integration_test.go
+++ b/resources/resource_transformers/tocss/scss/scss_integration_test.go
@@ -1,4 +1,4 @@
-// Copyright 2021 The Hugo Authors. All rights reserved.
+// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -328,6 +328,7 @@ Styles: {{ $r.RelPermalink }}
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
}
+// Issue #1239.
func TestRebuildAssetGetMatch(t *testing.T) {
t.Parallel()
if !scss.Supports() {
@@ -358,3 +359,61 @@ T1: {{ $r.Content }}
b.AssertFileContent("public/index.html", `color: blue`)
}
+
+func TestRebuildAssetMatchIssue12456(t *testing.T) {
+ t.Parallel()
+ if !scss.Supports() {
+ t.Skip()
+ }
+
+ files := `
+-- hugo.toml --
+disableKinds = ["term", "taxonomy", "section", "page"]
+disableLiveReload = true
+-- assets/a.scss --
+h1 {
+ color: red;
+}
+-- assets/dir/b.scss --
+h2 {
+ color: blue;
+}
+-- assets/dir/c.scss --
+h3 {
+ color: green;
+}
+-- layouts/index.html --
+{{ $a := slice (resources.Get "a.scss") }}
+{{ $b := resources.Match "dir/*.scss" }}
+
+{{/* Add styles in a specific order. */}}
+{{ $styles := slice $a $b }}
+
+{{ $stylesheets := slice }}
+ {{ range $styles }}
+ {{ $stylesheets = $stylesheets | collections.Append . }}
+{{ end }}
+
+
+{{ range $stylesheets }}
+ {{ with . | resources.ToCSS | fingerprint }}
+ <link as="style" href="{{ .RelPermalink }}" rel="preload stylesheet">
+ {{ end }}
+{{ end }}
+ `
+
+ b := hugolib.NewIntegrationTestBuilder(
+ hugolib.IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ NeedsOsFS: true,
+ Running: true,
+ // LogLevel: logg.LevelTrace,
+ }).Build()
+
+ b.AssertFileContent("public/index.html", `b.60a9f3bdc189ee8a857afd5b7e1b93ad1644de0873761a7c9bc84f781a821942.css`)
+
+ b.EditFiles("assets/dir/b.scss", `h2 { color: orange; }`).Build()
+
+ b.AssertFileContent("public/index.html", `b.46b2d77c7ffe37ee191678f72df991ecb1319f849957151654362f09b0ef467f.css`)
+}