Skip to content

Commit

Permalink
refactor: Add option to minify style code during SUI page build
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Jun 28, 2024
1 parent 80d28ab commit 481a958
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sui/core/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,20 @@ func (page *Page) BuildStyle(ctx *BuildContext, option *BuildOption) (string, er
code = cssRe.ReplaceAllStringFunc(code, func(css string) string {
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 {
return "", err
}

ctx.styles = append(ctx.styles, string(res))
return fmt.Sprintf("<style type=\"text/css\">\n%s\n</style>\n", res), nil
}

Expand Down

0 comments on commit 481a958

Please sign in to comment.