cssMin

105 views
Skip to first unread message

Maarten van Oudenniel

unread,
Feb 14, 2012, 12:41:25 PM2/14/12
to wro4j
Loving the maven extension, but i'm more a front-end person and i
would like to know how to use cssMin for single line declaration
(every selector on a new line) output.
Currently it works but it strips also all enters which makes it all in
one line which IE6 (still big part for our customers) chokes on. Is
there a way to set the options? I know you can set google closure
settings and normally i place them inside the first js file but it
seems to get ignored as well? Can someone tell me how to correct
cssMin then this tool becomes production ready for me :-)
Thanks for reading,
Maarten

Alex Objelean

unread,
Feb 14, 2012, 3:15:54 PM2/14/12
to wr...@googlegroups.com
Probably you know, but there is an alternative for maven plugin (called wro4j-runner) which was created for front-end peoples, just like you are :). It is a command line utility which can help you easily apply any processor from a command line. More details here:  http://code.google.com/p/wro4j/wiki/wro4jRunner

CssMin processor by default makes it all in one line (it is not configurable). You can try to use a different css minimizer, you can find all available processors here: http://code.google.com/p/wro4j/wiki/AvailableProcessors

If none of them does your job, you can disable minimization to make css much more readable. 
If there is a minimizer which does exactly what you need and it is open source, I could  try to create a processor for it, or you can do it (this requires some java coding).

I hope I've answered your question. 
If not, please let me know :).

Thanks,
Alex

Maarten van Oudenniel

unread,
Feb 14, 2012, 4:17:49 PM2/14/12
to wro4j
Thank you for this answer, I think YUI CSS compressor still can do the
job because there is an option to set a line-break '--line-break 0',
which is exactly what i want (each rule on single line) but was unable
to implement today (so not only tell which processor to run but also
it's own options, today yui didn't work at all), will look at your
wro4j-runner thanks once again!
The closure compiling part for js is doing fine btw, i had to do some
ant stuff for the requireJS modules (which part to aggregate or not).

Maarten

unread,
Feb 27, 2012, 8:09:52 AM2/27/12
to wro4j
How can we overrule processor's default and still using the maven
wro4j properties setup (property file with pre and post processors)?
On http://developer.yahoo.com/yui/compressor/#using you can see that
it does have options which exactly can do what i want (single
declarations per line). It is still buggy with media queries though
but that is something YUICSSmin related.

Alex Objelean

unread,
Feb 27, 2012, 8:31:23 AM2/27/12
to wr...@googlegroups.com
You can extend the ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory and use it as a custom manager factory. 

The  ConfigurableWroManagerFactory  is useful for providing custom processors. For example your custom implementation would look like this:

public class MyCustomManagerFactory extends ConfigurableWroManagerFactory {
  @Override
  protected Map<String, ResourcePreProcessor> createPreProcessorsMap() {
    final Map<String, ResourcePreProcessor> map = super.createPreProcessorsMap();
    ResourcePreProcessor customPreProcessor = // create processor
    map.put("customProcessor", customPreProcessor);
    return map;
  }

  @Override
  protected Map<String, ResourcePostProcessor> createPostProcessorsMap() {
    final Map<String, ResourcePostProcessor> map = super.createPostProcessorsMap();
    ResourcePostProcessor customPreProcessor = // create processor
    map.put("customProcessor", customPostProcessor);
    return map;
  }
}

The above example creates a custom pre & post processor. If you want to overrule an existing one, just use the same alias. For instance, use yuiCssMin key to replace the custom YuiCssMin processor with a new one.
At this point, you can use newly added (or overruled) processors in property file configuration. (I'll update the documentation with this example on wiki).

Let me know if you have other questions.

Cheers,
Alex
Reply all
Reply to author
Forward
0 new messages