davidB / yuicompressor-maven-plugin

maven's plugin to compress (Minify / Ofuscate / Aggregate) Javascript files and CSS files using YUI Compressor
http://davidb.github.io/yuicompressor-maven-plugin/
GNU Lesser General Public License v2.1
122 stars 48 forks source link

Folder structures in aggregate/exclude #60

Closed jmventar closed 11 years ago

jmventar commented 11 years ago

Congratulations for this tool, simple and effective. Is there any way to use exclusions for specific directories, not just JS files. Wildcards on directories don't work properly. It's possible to update documentation with all compress options? Not reflected in current documentation.

davidB commented 11 years ago

Hi,

Thank you for the kind words. Which new compress options aren't documented ? in :

Aggregate run on files, if you want to include/exclude every files of a directories you can use wildcard (like in the examples).

jmventar commented 11 years ago

Thank you for the docs I hadn't seen them before.

In my case folder exclusion would be a great feature because I have a lot of jquery components that all start as jquery.* in different folders(scripts, tools...) I also have my own jquery extended plugins that start as jquery.mycompany... and only this ones need to be compressed. When I have some time I will try to add this feature if you want.

davidB commented 11 years ago

Hi,

Have you tried somethings like (not tested) :

<includes>
  <include>**/jquery.mycompany**</include>
</includes>
<excludes>
  <exclude>**/jquery.**</exclude>
</excludes>

IIRC include has higher priority than exclude.

jmventar commented 11 years ago

Hi, I tried your fix with no result, also I noticed that using includes with excludes compressor stops working and there are no statistics.

Just tested with your example config and with other combinations. Here I put my configuration. It is almost finished. Maybe I'm gonna use excludes only.

<!-- Overwrite default file in target, same name but compressed --> 
<excludes>
<!-- General exclude all min and jquery -->
    <exclude>**/jquery**</exclude>
    <exclude>**/*min.js</exclude>
    <!-- Scripts folder -->
    <exclude>**/mycompany.snapengage*</exclude>
    <exclude>**/jshashtable*</exclude>
    <!-- Tools folder -->
        <!-- tools/colorpicker -->
        <exclude>**/colorpicker**</exclude>
        <exclude>**/layout**</exclude>
        <exclude>**/eye**</exclude>
        <exclude>**/utils**</exclude>
        <!-- tools/jqplot -->
        <exclude>**/*jqplot.js</exclude>
        <exclude>**/jqplot**</exclude>
        <!--tools/others -->
        <exclude>**/sh**</exclude>
</excludes>

Many thanks for your time.

jmventar commented 11 years ago

Also noticed this small bug found on thread : http://stackoverflow.com/questions/3836548/yui-compressor-maven-plugin-doesnt-compress-the-js-files

If you really have to have nosuffix then you need to change the execution phase to "package". Otherwise files are not compressed.

davidB commented 11 years ago

IIRC it's a BAD idea, see my comment on StackOverflow

jmventar commented 11 years ago

Thank you I saw your StackOverflow response and I tried second approach but finally I must use .min even if this isn't comfortable on development working with java templating engines (Apache Tiles, Thymeleaf).

I couldn't try first one because it's a Java Spring MVC project on an advanced stage and I'm not allowed to change folder structure.

The second approach also doesn't work for me because inside folder, let's say "scripts" for example there are files that will be compressed and ones that not. Following second approach only would copy files that this plugin compress and exclude all the others.

davidB commented 11 years ago

If you don't use the genered war by maven-war-plugin (no need, or creation via a other way like maven-assembly-plugin), it's fine. Else if you use package, the war file will not include compressed files (check the content).

On Fri, Mar 15, 2013 at 5:51 PM, jmventar notifications@github.com wrote:

Thank you I saw your StackOverflow response and I tried second approach but finally I must use the phase package.

I couldn't try first one because it's a Java Spring MVC project on an advanced stage v2.3 and I'm not allowed to change folder structure.

The second approach also doesn't work for me because inside folder, let's say "scripts" for example there are files that will be compressed and ones that not. Following second approach only would copy files that compress and exclude all the others.

Finally I must use the true because I usually work with templating java engines (Apache Tiles, Thymeleaf) and it's so tedious to spent time changing JS .min files for .js versions when developing.

— Reply to this email directly or view it on GitHubhttps://github.com/davidB/yuicompressor-maven-plugin/issues/60#issuecomment-14971940 .

jmventar commented 11 years ago

Thank you, finally I solved it and using "nosuffix". On maven-war-plugin I excluded all my scripts (the ones that will be compressed using your plugin) following this thread http://utku.hoydaablogs.com/2008/12/19/how-to-exclude-web-resources-in-maven-2/ (the other approaches to exclude content from war didn't work for me). When building the war it only places minified JS/CSS with original names.