blutorange / closure-compiler-maven-plugin

Combine and minimize JavaScript with Closure Compiler.
http://blutorange.github.com/closure-compiler-maven-plugin
Apache License 2.0
52 stars 6 forks source link

CSS minification/aggregation breaks percent measures #21

Closed blutorange closed 5 years ago

blutorange commented 5 years ago

Issue by nicStuff Wednesday Mar 29, 2017 at 12:05 GMT Originally opened as https://github.com/samaxes/minify-maven-plugin/issues/140


With version 1.7.6, and the following configuration

{ "bundles": [ { "type": "css", "name": "aaa.css", "files": [ "percent.css" ] } ] }

And the file percent.css being body { font-family:Arial, Helvetica, sans-serif; font-size:75.0%; color:#000; background:#cdcdcd; }

the resulting file "aaa.css" is body{font-family:Arial,Helvetica,sans-serif;font-size:75.0;color:#000;background:#cdcdcd}.

The percent sign has been lost in the process.

blutorange commented 5 years ago

Comment by nicStuff Wednesday Mar 29, 2017 at 13:31 GMT


A quick look on the source code doesn't reveal problems to me. Maybe this depends on YUI compressor https://github.com/yui/yuicompressor/issues/132

blutorange commented 5 years ago

Comment by samaxes Wednesday Mar 29, 2017 at 14:24 GMT


Yes, it's probably related to a YUI Compressor bug. Switching to Closure Compiler should fix your issue, can you please try?

blutorange commented 5 years ago

Comment by nicStuff Wednesday Mar 29, 2017 at 15:08 GMT


By setting <cssEngine>CLOSURE</cssEngine> (it's the CSS the one involved) the final file is empty: this doesn't surprise me since in https://github.com/samaxes/minify-maven-plugin/blob/master/src/main/java/com/samaxes/maven/minify/plugin/ProcessCSSFilesTask.java the YUI compressor engine is the only one taken into account.

Anyway, I compiled the plugin after having changed the artifact com.yahoo.platform.yui-yuicompressor to the version 2.4.7 and the output is right. Furthermore, YUI compressor 2.4.7 has always worked well for me, since I've been using https://github.com/davidB/yuicompressor-maven-plugin/ for years, which uses that version (but your plugin gives the flexibility needed for creating css/js groups).

So, is it reasonable to go back to 2.4.7? Are there any options available only in 2.4.8 that this plugin uses?

blutorange commented 5 years ago

Comment by nicStuff Wednesday Mar 29, 2017 at 15:27 GMT


I've created pull request #141

blutorange commented 5 years ago

Comment by samaxes Wednesday Mar 29, 2017 at 16:03 GMT


The problem is that I got asked to update to version 1.4.8 to support the latest JavaScript versions which YUI compressor 2.4.7 do not support. I would prefer if you can ask the YUI compressor team to release a new version with mentioned bug fixed. Then we can update the plugin to use that version.

blutorange commented 5 years ago

Comment by nicStuff Thursday Mar 30, 2017 at 11:19 GMT


It looks like the official YUI is no longer mantained by looking at the status of recent open issues (https://github.com/yui/yuicompressor/issues): the last one has been resolved on october 2016. Besides the issues, the last release is from 4 years ago, a lot of time.

Would it be viable to enable the closure engine for CSS and disable YUI? This way you could keep YUI 2.4.8 for javascript and the closure engine only for CSS.

blutorange commented 5 years ago

Comment by samaxes Thursday Mar 30, 2017 at 11:25 GMT


I tried that in the past, but there's a lot of work involved: https://github.com/google/closure-stylesheets/issues/101 Are you interested in helping?

blutorange commented 5 years ago

Comment by nicStuff Thursday Mar 30, 2017 at 11:38 GMT


Sure interested, but I wouldn't be able to give it the adequate time and effort to obtain a robust result. I'm just delaying the use of this plugin for seeing if we find a simple and quick and good solution: if we don't, I will simply use the version I installed locally in which I use YUI 2.4.7.

The point is that I really like this plugin and would like that CSS compression gets really resolved somehow. We could wrap the YUI 2.4.7 (or the bleeding edge of YUI or the commit that resolves that issue) in a new CSS compression engine, then use that engine here; we could take another CSS compression engine available on the market, but I struggle a bit to find one (this means that if it exists it's something not that tested/used, so something unreliable).

What do you think?

blutorange commented 5 years ago

CSS is out-of-scope now.