[ https://issues.apache.org/jira/browse/TAP5-2753?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17709942#comment-17709942 ]
Ben Weidig commented on TAP5-2753: ---------------------------------- Hi [~lrein], the CssCompressor is based on the YUI Compressor [https://github.com/yui/yuicompressor], which is a dead project for quite some time now. There are a lot of minor issues, especially regarding newer CSS features. It's been on my to-do list for a long time to think about a solution to keep it functioning and make it more maintainable without introducing another dependency. I haven't tested it yet, but I believe the code block can't be removed in general, as spaces are required between operators, see https://developer.mozilla.org/fr/docs/Web/CSS/calc and https://github.com/yui/yuicompressor/issues/238 However, maybe the regex could be changed for "-" to ignore variables. If you need an immediate fix, you could override the CSS ResourceMinimizer, which we did for our projects due to an other issues with CssCompressor: {code:java} @Contribute(ResourceMinimizer.class) @Primary public static void setupDefaultResourceMinimizers(MappedConfiguration<String, ResourceMinimizer> conf) { conf.overrideInstance("text/css", CustomCssCompressor.class); } {code} The CssCompressor isn't a ResourceMinimizer, but we made the CustomCssCompressor one by moving the code from org.apache.tapestry5.internal.webresources.CSSMinimizer directly into it. Long term, I think it makes sense to move the test CSS files from the YUI project over to Tapestry, so the CssCompressor can be changed without breaking other features. > CssCompressor for CSS files produces wrong minification if calc contains > variables. > ----------------------------------------------------------------------------------- > > Key: TAP5-2753 > URL: https://issues.apache.org/jira/browse/TAP5-2753 > Project: Tapestry 5 > Issue Type: Bug > Components: tapestry-webresources > Affects Versions: 5.8.2 > Reporter: LRein > Priority: Minor > > CssCompressor for CSS files produces wrong minification if calc contains > variables. > {code:css} > .some-class > { > padding-top: calc(10px + var(--default-page-header-height)); > } > {code} > produces spaces between dashes within the variable: > {code:css} > .some-class > { > padding-top: calc(10px + var( - - default - page - header - height)); > } > {code} > Just removing this code block at the end helps: > {code:java} > // Add spaces back in between operators for css calc function > // https://developer.mozilla.org/en-US/docs/Web/CSS/calc > // Added by Eric Arnol-Martin (earnolmar...@gmail.com) > sb = new StringBuffer(); > p = Pattern.compile("calc\\([^\\)]*\\)"); > m = p.matcher(css); > while (m.find()) { > String s = m.group(); > > s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\+", " + "); > s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\-", " - "); > s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\*", " * "); > s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\/", " / "); > > m.appendReplacement(sb, s); > } > m.appendTail(sb); > css = sb.toString(); > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)