Merge pull request #636 from trheyi/main
refactor: Add option to minify style code during SUI page build
This commit is contained in:
commit
23ea6c5e50
1 changed files with 8 additions and 2 deletions
|
|
@ -338,14 +338,20 @@ func (page *Page) BuildStyle(ctx *BuildContext, option *BuildOption) (string, er
|
||||||
code = cssRe.ReplaceAllStringFunc(code, func(css string) string {
|
code = cssRe.ReplaceAllStringFunc(code, func(css string) string {
|
||||||
return fmt.Sprintf("[s\\:cn=%s] %s", option.ComponentName, css)
|
return fmt.Sprintf("[s\\:cn=%s] %s", option.ComponentName, css)
|
||||||
})
|
})
|
||||||
|
res, err := page.CompileCSS([]byte(code), option.StyleMinify)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.styles = append(ctx.styles, string(res))
|
||||||
|
return fmt.Sprintf("<style type=\"text/css\">\n%s\n</style>\n", res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := page.CompileCSS([]byte(code), false)
|
res, err := page.CompileCSS([]byte(code), option.StyleMinify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.styles = append(ctx.styles, string(res))
|
|
||||||
return fmt.Sprintf("<style type=\"text/css\">\n%s\n</style>\n", res), nil
|
return fmt.Sprintf("<style type=\"text/css\">\n%s\n</style>\n", res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue