mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
@@ -74,8 +74,10 @@ func New(fs *filesystems.SourceFilesystem, rs *resources.Spec) (*Client, error)
|
||||
case godartsass.LogEventTypeDebug:
|
||||
// Log as Info for now, we may adjust this if it gets too chatty.
|
||||
infol.Log(logg.String(message))
|
||||
case godartsass.LogEventTypeDeprecated:
|
||||
warnl.Logf("DEPRECATED [%s]: %s", event.DeprecationType, message)
|
||||
default:
|
||||
// The rest are either deprecations or @warn statements.
|
||||
// The rest are @warn statements.
|
||||
warnl.Log(logg.String(message))
|
||||
}
|
||||
},
|
||||
@@ -151,6 +153,11 @@ type Options struct {
|
||||
// @use "hugo:vars";
|
||||
// $color: vars.$color;
|
||||
Vars map[string]any
|
||||
|
||||
// Deprecations IDs in this slice will be silenced.
|
||||
// The IDs can be found in the Dart Sass log output, e.g. "import" in
|
||||
// WARN Dart Sass: DEPRECATED [import].
|
||||
SilenceDeprecations []string
|
||||
}
|
||||
|
||||
func decodeOptions(m map[string]any) (opts Options, err error) {
|
||||
|
@@ -605,3 +605,38 @@ module hugo-github-issue-12849
|
||||
|
||||
b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
|
||||
}
|
||||
|
||||
func TestIgnoreDeprecationWarnings(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !dartsass.Supports() {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['page','section','rss','sitemap','taxonomy','term']
|
||||
-- assets/scss/main.scss --
|
||||
@import "moo";
|
||||
-- node_modules/foo/_moo.scss --
|
||||
$moolor: #fff;
|
||||
|
||||
moo {
|
||||
color: $moolor;
|
||||
}
|
||||
-- config.toml --
|
||||
-- layouts/index.html --
|
||||
{{ $cssOpts := (dict "includePaths" (slice "node_modules/foo") "transpiler" "dartsass" ) }}
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts | minify }}
|
||||
T1: {{ $r.Content }}
|
||||
`
|
||||
|
||||
b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWarn())
|
||||
b.AssertLogContains("Dart Sass: DEPRECATED [import]")
|
||||
b.AssertFileContent("public/index.html", `moo{color:#fff}`)
|
||||
|
||||
files = strings.ReplaceAll(files, `"transpiler" "dartsass"`, `"transpiler" "dartsass" "silenceDeprecations" (slice "import")`)
|
||||
|
||||
b = hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWarn())
|
||||
b.AssertLogContains("! Dart Sass: DEPRECATED [import]")
|
||||
b.AssertFileContent("public/index.html", `moo{color:#fff}`)
|
||||
}
|
||||
|
@@ -89,6 +89,7 @@ func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error {
|
||||
OutputStyle: godartsass.ParseOutputStyle(opts.OutputStyle),
|
||||
EnableSourceMap: opts.EnableSourceMap,
|
||||
SourceMapIncludeSources: opts.SourceMapIncludeSources,
|
||||
SilenceDeprecations: opts.SilenceDeprecations,
|
||||
}
|
||||
|
||||
// Append any workDir relative include paths
|
||||
|
Reference in New Issue
Block a user