I am trying to gzip js & css files during build using wro4j Maven

I'm trying to gzip js and css files during build using wro4j Maven (called via m2e-wtp - using Eclipse Luna) but it doesn't work. I tried it with version 1.7.5

, 1.7.7

.

Below is the configuration:

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

(not clear which one needs to be used to solve the build time!).

Can anyone tell me how to gzip at build time? Thank.

+3


source to share


2 answers


I wrote a simple Maven plugin to just do this: gzip JS and CSS files.



https://github.com/manikantag/em-maven-resource-optimizer

+1


source


The maven plugin is responsible for creating simple minified resources. It shouldn't create gzip content. To serve gzipped content, you must use a custom filter or configure your container to handle the gzipped operation.



0


source







All Articles