From 481a9589acef349441bbb52a17ba71128e44e4bc Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 28 Jun 2024 20:31:30 +0800 Subject: [PATCH] refactor: Add option to minify style code during SUI page build --- sui/core/build.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sui/core/build.go b/sui/core/build.go index f7fcfdfb9..af39383cf 100644 --- a/sui/core/build.go +++ b/sui/core/build.go @@ -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("\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("\n", res), nil }