2012-03-30 70 views
2

我可以在聚合后为压缩文件设置Maven YUI Compressor,因为我想排除“sources”目录,其中包含用于聚合的文件,然后压缩聚合文件。Maven YUI Compressor:聚合后压缩

比如我有一些.js文件,文件的/JS /来源/ MYLIB/内,所有这些文件合并成一个文件/js/mylib.js而锐压缩机聚集阶段。在pom.xml中,我将yui-compressor配置为排除整个库,但yui-compressor在汇总之前执行“压缩”目标,所以我有未压缩的合并文件。我需要解决这个不知何故

+0

您是否在最后的@SquAreRoot中找到了解决方案? – Patrick 2013-07-24 15:51:41

回答

1

我们可以把它转过来说:压缩后的聚合?如果是这样,我有同样的问题,并与以下它为我解决。

这个技巧似乎是将输出文件放在目标目录中而不是源文件中。这样,您可以包含在聚合中缩小的文件。

已经缩小的文件然后通过basedir变量进行处理。

<executions> 
    <execution> 
     <goals> 
     <goal>compress</goal> 
     </goals> 
    </execution> 
    </executions>   
    <configuration> 
    <excludes> 
     <exclude>**/*-min.js</exclude> 
     <exclude>**/*.min.js</exclude> 
     <exclude>**/*.css</exclude> 
    </excludes> 
    <removeIncluded>false</removeIncluded> 
    <jswarn>false</jswarn> 
    <aggregations> 
     <aggregation> 
      <insertNewLine>true</insertNewLine> 
      <removeIncluded>false</removeIncluded> 
      <includes> 
       <!-- these exist only in target dir. the original was json2.js & bootstrap.tabs.js --> 
       <include>**/bootstrap-tabs-min.js</include> 
       <include>**/json2-min.js</include> 
       <!-- use originals for the ones already minified --> 
       <include>${basedir}/src/main/webapp/js/backbone-min.js</include> 
      </includes> 
      <output>${project.build.directory}/${project.build.finalName}/js/test.js</output> 
     </aggregation> 
    </aggregations> 
    </configuration> 
+0

那么,在这种情况下,我不会有原始未记录的文件,但我想保留这些文件以缩小“开发人员”用户组的范围,以简化生产中的问题解决。但是,好吧,我想我可以通过任务从源文件根 – SquAreRoot 2012-04-10 06:37:09

+0

复制未经文件化的文件。我认为 false 将确保原始文件保留。顺便说一句,我目前正在检查这个插件,因为我有上面的其他奇怪的问题:http://maven-samaxes-plugin.googlecode.com/svn/sites/maven-minify-plugin/minify-mojo。 HTML – demiurg 2012-04-12 18:59:39