]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
scss: Handle single-file sourcemaps correctly
authorJenny Rakoczy <jennyrock42@gmail.com>
Mon, 5 Sep 2022 18:54:34 +0000 (14:54 -0400)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 6 Sep 2022 08:52:28 +0000 (10:52 +0200)
Simple sites may only have one css file. Update the replace directive to
correctly match single-file sourcemaps and multi-file sourcemaps.

Verified locally with and without SASS and CSS imports.

Fixes #8174

resources/resource_transformers/tocss/scss/tocss.go

index 57ac16711550fea3d38cda6bc9b20e803149d294..10bd1f6f8d8cd53eb7218103dda3e2b1a852db9b 100644 (file)
@@ -163,7 +163,7 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx
                // This is a workaround for what looks like a bug in Libsass. But
                // getting this resolution correct in tools like Chrome Workspaces
                // is important enough to go this extra mile.
-               mapContent := strings.Replace(res.SourceMapContent, `stdin",`, fmt.Sprintf("%s\",", sourcePath), 1)
+               mapContent := strings.Replace(res.SourceMapContent, `stdin"`, fmt.Sprintf("%s\"", sourcePath), 1)
 
                return ctx.PublishSourceMap(mapContent)
        }