Reputation: 8500
I m trying to gzip js & css files at build time using wro4j Maven (invoked via m2e-wtp - using Eclipse Luna), but it is not working. I've tried with 1.7.5
, 1.7.7
versions.
Below is config I've:
wro.xml:
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<executions>
<!-- JS minification -->
<execution>
<id>js-minify</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<debug>true</debug>
<targetGroups>angular-deps,app-bundle</targetGroups>
<minimize>true</minimize>
<!-- provide Google Closure compiler options using custom factory --><wroManagerFactory>com.manikanta.wro4j.maven.CustomWroManagerFactory</wroManagerFactory>
<groupNameMappingFile>${basedir}/src/main/webapp/js-min/group-mapping.properties</groupNameMappingFile>
<ignoreMissingResources>false</ignoreMissingResources>
<gzipEnabled>true</gzipEnabled>
</configuration>
</execution>
<!-- CSS minification -->
<execution>
<id>css-minify</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<targetGroups>styles</targetGroups>
<minimize>true</minimize>
<ignoreMissingResources>true</ignoreMissingResources>
<groupNameMappingFile>${basedir}/src/main/webapp/css-min/group-mapping.properties</groupNameMappingFile>
</configuration>
</execution>
</executions>
<configuration>
<contextFolder>${basedir}/src/main/webapp/</contextFolder>
<!-- <destinationFolder>${project.build.directory}/${project.build.finalName}</destinationFolder> -->
<destinationFolder>${basedir}/src/main/webapp/bundle</destinationFolder>
<jsDestinationFolder>${basedir}/src/main/webapp/js-min</jsDestinationFolder>
<cssDestinationFolder>${basedir}/src/main/webapp/css-min</cssDestinationFolder>
<wroFile>${basedir}/src/main/resources/wro.xml</wroFile>
<extraConfigFile>${basedir}/src/main/resources/wro.properties</extraConfigFile>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
<ignoreMissingResources>false</ignoreMissingResources>
<incrementalBuildEnabled>true</incrementalBuildEnabled>
</configuration>
</plugin>
wro.properties:
# General Configuration
debug=true
gzipResources=true
gzipEnabled=true
#List of preProcessors
preProcessors=googleClosureSimple
#List of postProcessors
postProcessors=yuiCssMin
# naming strategy
hashStrategy=CRC32
namingStrategy=hashEncoder
sourceMapsDestinationFolder=d:/__sourcemaps
incrementalBuildEnabled=true
parallelPreprocessing=true
parallelProcessing=true
I tried both gzipResources
and gzipEnabled
(it is not clear which once to use for build time solution!).
Can someone tell me how to do gzip at build time? Thanks.
Upvotes: 3
Views: 1592
Reputation: 8500
I've written a simple Maven plugin to just do this: gzip JS & CSS files.
https://github.com/manikantag/em-maven-resource-optimizer
Upvotes: 1
Reputation: 4133
The maven plugin is responsible for producing plain minimimized resources. It is not supposed to produce gzipped content. In order to serve gzipped content, you should use a specialized filter or configure your container to handle the gzip operation.
Upvotes: 0