mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
deps: Update to github.com/tdewolff/minify v2.9.4
This commit is contained in:
parent
05a2289292
commit
b254532b52
5 changed files with 53 additions and 9 deletions
2
go.mod
2
go.mod
|
@ -51,7 +51,7 @@ require (
|
||||||
github.com/spf13/jwalterweatherman v1.1.0
|
github.com/spf13/jwalterweatherman v1.1.0
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/spf13/viper v1.7.1
|
github.com/spf13/viper v1.7.1
|
||||||
github.com/tdewolff/minify/v2 v2.6.2
|
github.com/tdewolff/minify/v2 v2.9.4
|
||||||
github.com/yuin/goldmark v1.2.1
|
github.com/yuin/goldmark v1.2.1
|
||||||
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
|
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
|
||||||
gocloud.dev v0.15.0
|
gocloud.dev v0.15.0
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -455,8 +455,12 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tdewolff/minify/v2 v2.6.2 h1:Jaod6aSABWmhftvnxvXogxcEoQt6yogfFeZgIQEMPOw=
|
github.com/tdewolff/minify/v2 v2.6.2 h1:Jaod6aSABWmhftvnxvXogxcEoQt6yogfFeZgIQEMPOw=
|
||||||
github.com/tdewolff/minify/v2 v2.6.2/go.mod h1:BkDSm8aMMT0ALGmpt7j3Ra7nLUgZL0qhyrAHXwxcy5w=
|
github.com/tdewolff/minify/v2 v2.6.2/go.mod h1:BkDSm8aMMT0ALGmpt7j3Ra7nLUgZL0qhyrAHXwxcy5w=
|
||||||
|
github.com/tdewolff/minify/v2 v2.9.4 h1:sOqgmowmkZWmHZ0AqIFS300VvCCkgDNTw1eWw1tnNCY=
|
||||||
|
github.com/tdewolff/minify/v2 v2.9.4/go.mod h1:4SrPavRSPLpv4U4jqV8jzSjiEuq2BH+BPgxorMkGrhc=
|
||||||
github.com/tdewolff/parse/v2 v2.4.2 h1:Bu2Qv6wepkc+Ou7iB/qHjAhEImlAP5vedzlQRUdj3BI=
|
github.com/tdewolff/parse/v2 v2.4.2 h1:Bu2Qv6wepkc+Ou7iB/qHjAhEImlAP5vedzlQRUdj3BI=
|
||||||
github.com/tdewolff/parse/v2 v2.4.2/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
|
github.com/tdewolff/parse/v2 v2.4.2/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
|
||||||
|
github.com/tdewolff/parse/v2 v2.5.2 h1:OIUAejEkj9Oj6N1q18xg7ByYkpQ0xf4nA1aAH5nqxks=
|
||||||
|
github.com/tdewolff/parse/v2 v2.5.2/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
|
||||||
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
|
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
|
||||||
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||||
github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
|
@ -592,6 +596,8 @@ golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HX
|
||||||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w=
|
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w=
|
||||||
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c h1:UIcGWL6/wpCfyGuJnRFJRurA+yj8RrW7Q6x2YMCXt6c=
|
||||||
|
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
|
||||||
|
|
|
@ -489,7 +489,7 @@ Min HTML: {{ ( resources.Get "mydata/html1.html" | resources.Minify ).Content |
|
||||||
`)
|
`)
|
||||||
}, func(b *sitesBuilder) {
|
}, func(b *sitesBuilder) {
|
||||||
b.AssertFileContent("public/index.html", `Min CSS: h1{font-style:bold}`)
|
b.AssertFileContent("public/index.html", `Min CSS: h1{font-style:bold}`)
|
||||||
b.AssertFileContent("public/index.html", `Min JS: var x;x=5;document.getElementById("demo").innerHTML=x*10;`)
|
b.AssertFileContent("public/index.html", `Min JS: var x;x=5,document.getElementById("demo").innerHTML=x*10`)
|
||||||
b.AssertFileContent("public/index.html", `Min JSON: {"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}`)
|
b.AssertFileContent("public/index.html", `Min JSON: {"employees":[{"firstName":"John","lastName":"Doe"},{"firstName":"Anna","lastName":"Smith"},{"firstName":"Peter","lastName":"Jones"}]}`)
|
||||||
b.AssertFileContent("public/index.html", `Min XML: <hello><world>Hugo Rocks!</<world></hello>`)
|
b.AssertFileContent("public/index.html", `Min XML: <hello><world>Hugo Rocks!</<world></hello>`)
|
||||||
b.AssertFileContent("public/index.html", `Min SVG: <svg height="100" width="100"><path d="M1e2 1e2H3e2 2e2z"/></svg>`)
|
b.AssertFileContent("public/index.html", `Min SVG: <svg height="100" width="100"><path d="M1e2 1e2H3e2 2e2z"/></svg>`)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
"github.com/gohugoio/hugo/docshelper"
|
"github.com/gohugoio/hugo/docshelper"
|
||||||
"github.com/gohugoio/hugo/parser"
|
"github.com/gohugoio/hugo/parser"
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/tdewolff/minify/v2/css"
|
"github.com/tdewolff/minify/v2/css"
|
||||||
|
@ -35,18 +36,16 @@ var defaultTdewolffConfig = tdewolffConfig{
|
||||||
KeepEndTags: true,
|
KeepEndTags: true,
|
||||||
KeepDefaultAttrVals: true,
|
KeepDefaultAttrVals: true,
|
||||||
KeepWhitespace: false,
|
KeepWhitespace: false,
|
||||||
// KeepQuotes: false, >= v2.6.2
|
KeepQuotes: false,
|
||||||
},
|
},
|
||||||
CSS: css.Minifier{
|
CSS: css.Minifier{
|
||||||
Decimals: -1, // will be deprecated
|
Precision: 0,
|
||||||
// Precision: 0, // use Precision with >= v2.7.0
|
|
||||||
KeepCSS2: true,
|
KeepCSS2: true,
|
||||||
},
|
},
|
||||||
JS: js.Minifier{},
|
JS: js.Minifier{},
|
||||||
JSON: json.Minifier{},
|
JSON: json.Minifier{},
|
||||||
SVG: svg.Minifier{
|
SVG: svg.Minifier{
|
||||||
Decimals: -1, // will be deprecated
|
Precision: 0,
|
||||||
// Precision: 0, // use Precision with >= v2.7.0
|
|
||||||
},
|
},
|
||||||
XML: xml.Minifier{
|
XML: xml.Minifier{
|
||||||
KeepWhitespace: false,
|
KeepWhitespace: false,
|
||||||
|
@ -99,6 +98,22 @@ func decodeConfig(cfg config.Provider) (conf minifyConfig, err error) {
|
||||||
|
|
||||||
m := maps.ToStringMap(v)
|
m := maps.ToStringMap(v)
|
||||||
|
|
||||||
|
// Handle upstream renames.
|
||||||
|
if td, found := m["tdewolff"]; found {
|
||||||
|
tdm := cast.ToStringMap(td)
|
||||||
|
for _, key := range []string{"css", "svg"} {
|
||||||
|
if v, found := tdm[key]; found {
|
||||||
|
vm := cast.ToStringMap(v)
|
||||||
|
if vv, found := vm["decimal"]; found {
|
||||||
|
vvi := cast.ToInt(vv)
|
||||||
|
if vvi > 0 {
|
||||||
|
vm["precision"] = vvi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = mapstructure.WeakDecode(m, &conf)
|
err = mapstructure.WeakDecode(m, &conf)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestNew(t *testing.T) {
|
||||||
var rawJS string
|
var rawJS string
|
||||||
var minJS string
|
var minJS string
|
||||||
rawJS = " var foo =1 ; foo ++ ; "
|
rawJS = " var foo =1 ; foo ++ ; "
|
||||||
minJS = "var foo=1;foo++;"
|
minJS = "var foo=1;foo++"
|
||||||
|
|
||||||
var rawJSON string
|
var rawJSON string
|
||||||
var minJSON string
|
var minJSON string
|
||||||
|
@ -168,3 +168,26 @@ func TestBugs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renamed to Precision in v2.7.0. Check that we support both.
|
||||||
|
func TestDecodeConfigDecimalIsNowPrecision(t *testing.T) {
|
||||||
|
c := qt.New(t)
|
||||||
|
v := viper.New()
|
||||||
|
v.Set("minify", map[string]interface{}{
|
||||||
|
"disablexml": true,
|
||||||
|
"tdewolff": map[string]interface{}{
|
||||||
|
"css": map[string]interface{}{
|
||||||
|
"decimal": 3,
|
||||||
|
},
|
||||||
|
"svg": map[string]interface{}{
|
||||||
|
"decimal": 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
conf, err := decodeConfig(v)
|
||||||
|
|
||||||
|
c.Assert(err, qt.IsNil)
|
||||||
|
c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 3)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue