dartsass: Enable deprecation, @warn and @debug logging

* @warn and Sass deprecations are printed as WARN
* @debug is currently logged as INFO (needs the `--verbose` flag). We may adjust this if it gets too chatty.

Fixes #9683
This commit is contained in:
Bjørn Erik Pedersen
2022-03-17 17:22:34 +01:00
parent 64afb7ca51
commit 423594e03a
6 changed files with 66 additions and 12 deletions

View File

@@ -39,7 +39,8 @@ import (
const (
// See https://github.com/sass/dart-sass-embedded/issues/24
stdinPlaceholder = "HUGOSTDIN"
// Note: This prefix must be all lower case.
stdinPrefix = "hugostdin:"
dartSassEmbeddedBinaryName = "dart-sass-embedded"
)
@@ -75,9 +76,14 @@ func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error {
}
baseDir := path.Dir(ctx.SourcePath)
filename := stdinPrefix
if ctx.SourcePath != "" {
filename += t.c.sfs.RealFilename(ctx.SourcePath)
}
args := godartsass.Args{
URL: stdinPlaceholder,
URL: filename,
IncludePaths: t.c.sfs.RealDirs(baseDir),
ImportResolver: importResolver{
baseDir: baseDir,
@@ -106,11 +112,8 @@ func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error {
start := sassErr.Span.Start
context := strings.TrimSpace(sassErr.Span.Context)
filename, _ := urlToFilename(sassErr.Span.Url)
if filename == stdinPlaceholder {
if ctx.SourcePath == "" {
return sassErr
}
filename = t.c.sfs.RealFilename(ctx.SourcePath)
if strings.HasPrefix(filename, stdinPrefix) {
filename = filename[len(stdinPrefix):]
}
offsetMatcher := func(m herrors.LineMatcher) bool {