Example project minifying js & css with Maven
This is a working pom.xml file using the maven-minify-plugin, gziping the result and replacing the current css/js links in configured files to the minified version.
This is what happens
- Creates one css file from existing css-files (you need to specify each CSS in the pom.xml, to be able to be sure the order is right)
- Creates one js file from existing js-files (you need to specify each JS in the pom.xml, to be able to be sure the order is right)
- Minifies them
- Give the minified js and css files unique names for each release (right now using time stamp)
- Creates gzipped versions
How to use it
mvn clean package
What you need to do
Configure your web server to pick the gz-versions of the files.
Structure of the project
The /src/-tree holds an example setup with two css & two js files that are concated & minified and example files that hold references/links to the actual js/css files.
The naming of the css/js file uses the current date/time, not so good if you releasing multiple times a day, needs to be changed!