我正在尝试gzip js&css文件,但它不起作用。我尝试过1.7.5
、1.7.7
版本。
以下是我的配置:
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>
写入属性:
# 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
我尝试了gzipResources
和gzipEnabled
(不清楚在构建时使用哪一个!)。
有人能告诉我如何在构建时执行gzip吗?谢谢
我已经编写了一个简单的Maven插件来做到这一点:gzip JS&CSS文件。
https://github.com/manikantag/em-maven-resource-optimizer
maven插件负责生成简单的最小化资源。它不应该生成gzip内容。为了提供gzip内容,您应该使用专门的过滤器或配置容器来处理gzip操作。