Transparent javascript and css compression with Maven3 and Yuicompressor
There are a lot of ressources on how to use YUIcompressor on a Maven project, but several examples don’t work with Maven3, or don’t allow to replace javascript and css by their compressed version transparently.
The following example will compress files transparently when packaging the webapp in a WAR file, and keep original files for development.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<warSourceExcludes>**/*.css,**/*.js</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<executions>
<execution>
<id>compressyui</id>
<phase>prepare-package</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<nosuffix>true</nosuffix>
</configuration>
</plugin>







