Skip to content

Commit

Permalink
Fix Sass imports of on the form index.{scss,sass}
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Dec 10, 2024
1 parent 7b69218 commit 1f0e790
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,23 +577,25 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.imports]]
path = "github.com/gohugoio/hugoTestModule2"
[[module.imports.mounts]]
[[module.mounts]]
source = "miscellaneous/sass"
target = "assets/sass"
-- go.mod --
module hugo-github-issue-12849
-- layouts/index.html --
{{ $opts := dict "transpiler" "dartsass" "outputStyle" "compressed" }}
{{ (resources.Get "sass/main.scss" | toCSS $opts).Content }}
-- assets/sass/main.scss --
@use "foo"; // directory with index file from OS file system
@use "bar"; // directory with index file from module mount
-- assets/sass/foo/_index.scss --
.foo {color: red;}
@use "foo1"; // directory with _index file from OS file system
@use "bar1"; // directory with _index file from module mount
@use "foo2"; // directory with index file from OS file system
@use "bar2"; // directory with index file from module mount
-- assets/sass/foo1/_index.scss --
.foo1 {color: red;}
-- miscellaneous/sass/bar1/_index.scss --
.bar1 {color: blue;}
-- assets/sass/foo2/index.scss --
.foo2 {color: red;}
-- miscellaneous/sass/bar2/index.scss --
.bar2 {color: blue;}
`

b := hugolib.NewIntegrationTestBuilder(
Expand All @@ -603,7 +605,7 @@ module hugo-github-issue-12849
TxtarString: files,
}).Build()

b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
}

func TestIgnoreDeprecationWarnings(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (t importResolver) CanonicalizeURL(url string) (string, error) {
"_%s.sass", "%s.sass",
"_%s.css", "%s.css",
"%s/_index.scss", "%s/_index.sass",
"%s/index.scss", "%s/index.sass",
}
}

Expand Down
26 changes: 14 additions & 12 deletions resources/resource_transformers/tocss/scss/scss_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,23 +432,25 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.imports]]
path = "github.com/gohugoio/hugoTestModule2"
[[module.imports.mounts]]
[[module.mounts]]
source = "miscellaneous/sass"
target = "assets/sass"
-- go.mod --
module hugo-github-issue-12849
-- layouts/index.html --
{{ $opts := dict "transpiler" "libsass" "outputStyle" "compressed" }}
{{ (resources.Get "sass/main.scss" | toCSS $opts).Content }}
-- assets/sass/main.scss --
@import "foo"; // directory with index file from OS file system
@import "bar"; // directory with index file from module mount
-- assets/sass/foo/_index.scss --
.foo {color: red;}
@import "foo1"; // directory with _index file from OS file system
@import "bar1"; // directory with _index file from module mount
@import "foo2"; // directory with index file from OS file system
@import "bar2"; // directory with index file from module mount
-- assets/sass/foo1/_index.scss --
.foo1 {color: red;}
-- miscellaneous/sass/bar1/_index.scss --
.bar1 {color: blue;}
-- assets/sass/foo2/index.scss --
.foo2 {color: red;}
-- miscellaneous/sass/bar2/index.scss --
.bar2 {color: blue;}
`

b := hugolib.NewIntegrationTestBuilder(
Expand All @@ -458,5 +460,5 @@ module hugo-github-issue-12849
TxtarString: files,
}).Build()

b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
}
1 change: 1 addition & 0 deletions resources/resource_transformers/tocss/scss/tocss.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx
"_%s.scss", "%s.scss",
"_%s.sass", "%s.sass",
"%s/_index.scss", "%s/_index.sass",
"%s/index.scss", "%s/index.sass",
}
}

Expand Down

0 comments on commit 1f0e790

Please sign in to comment.