I am working on a legacy project, it's a Vaadin component which uses Maven YUI plugin to minify and concatenate the javascript files. There are 40 js files.
The YUI plugin works as it should, minifying the 40 js files and concatenating them into one file (which is then referenced with @javascript
in Vaadin).
Because of the minification development for new features is painful, but I can't remove the YUI plugin because then I'd need to add a @javascript
annotation for all 40 js files.
Is there a way to make YUI aggregate but not minify. I had read the docs and tried changing the goals (i.e. to jslint only) but it seems I can't aggregate if I don't use the compress
goal.
Am I missing something here?
Here's my YUI config as it stands:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>jslint</id>
<goals>
<goal>jslint</goal>
</goals>
<configuration>
<includes>
<include>**/*.js</include>
</includes>
<excludes>
<exclude>**/VAADIN/js/*.js</exclude>
<exclude>**/depends/*.js</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>minify</id>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<force>true</force>
<excludeWarSourceDirectory>true</excludeWarSourceDirectory>
<linebreakpos>-1</linebreakpos>
<aggregations>
<aggregation>
<inputDir>target/classes/[path]/components</inputDir>
<removeIncluded>true</removeIncluded>
<output>${project.build.directory}/classes/[path].js</output>
<includes>
<include>**/*.js</include>
<include>**/Copyright.txt</include>
</includes>
<excludes>
<exclude>**/depends/d3_3.4.6.js</exclude>
</excludes>
</aggregation>
</aggregations>
<includes>
<include>**/*.js</include>
<include>**/[project.name].css</include>
</includes>
<excludes>
<exclude>**/depends/*.js</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
N.b. I've also tried the above with the aggregation config in the jslint goal with no joy.
There must be a way to stop the compression (I know YUI is a compression plugin, but it has other functions (such as lint) so I'd assume you can turn compression off). Also, Vaadin's @javascript
annotation takes a comma separated list of js files. I feel adding 40 would be way too much, but maybe there is a way for @javascript
to take a directory. (docs don't mention this though)
Decided to anwers this one I found a solution, party for anyone finding it and partly because it didnt get any other answers.
The solution was inspired by this answer by someone asking the opersite of what I needed. @Mady pointed out the different includes/excludes in the plugin config
Short story long, you can exclude ALL .js files in the minifyer but included them in the agreegator:
<execution>
<id>minify</id>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<force>true</force>
<excludeWarSourceDirectory>true</excludeWarSourceDirectory>
<linebreakpos>-1</linebreakpos>
<aggregations>
<aggregation>
<includes>
<include>**/*.js</include> <!-- INCLUDES FOR CONCATENATION -->
</includes>
</aggregation>
</aggregations>
<excludes>
<exclude>**/*.js</exclude> <!-- EXCLUDE ALL JS FROM MINIFICATION -->
</excludes>
</configuration>
</execution>