2015-07-22 147 views
3

我正在使用舊項目,它是一個Vaadin組件,它使用Maven YUI插件來縮小和連接javascript文件。有40個js文件。Maven YUI壓縮器,concat但不縮小(關閉壓縮)

YUI插件的工作原理是,將40個js文件縮小並將它們連接成一個文件(然後在Vaadin中使用@javascript進行引用)。

由於新功能的縮小開發很痛苦,但我無法刪除YUI插件,因爲那樣我就需要爲所有40個js文件添加一個@javascript註釋。

有沒有辦法讓YUI聚合,但不是 minify。我已經閱讀了文檔,並試圖改變目標(即僅限於jslint),但如果我不使用compress目標,似乎我無法聚合。

我在這裏錯過了什麼嗎?

這裏是我的YUI的配置,因爲它代表:

<plugin> 
    <groupId>net.alchim31.maven</groupId> 
    <artifactId>yuicompressor-maven-plugin</artifactId> 
    <version>1.5.1</version> 
    <executions> 
    <execution> 
     <id>jslint</id> 
     <goals> 
     <goal>jslint</goal> 
     </goals> 
     <configuration> 
     <includes> 
     <include>**/*.js</include> 
     </includes> 
     <excludes> 
     <exclude>**/VAADIN/js/*.js</exclude> 
     <exclude>**/depends/*.js</exclude> 
     </excludes> 
     </configuration> 
    </execution> 
    <execution> 
    <id>minify</id> 
    <goals> 
    <goal>compress</goal> 
    </goals> 
    <configuration> 
    <nosuffix>true</nosuffix> 
    <force>true</force>  
    <excludeWarSourceDirectory>true</excludeWarSourceDirectory> 
    <linebreakpos>-1</linebreakpos> 
    <aggregations> 
    <aggregation> 
     <inputDir>target/classes/[path]/components</inputDir> 
     <removeIncluded>true</removeIncluded> 
     <output>${project.build.directory}/classes/[path].js</output> 
    <includes> 
     <include>**/*.js</include> 
     <include>**/Copyright.txt</include> 
    </includes> 
    <excludes> 
     <exclude>**/depends/d3_3.4.6.js</exclude> 
    </excludes> 
    </aggregation> 
    </aggregations> 
    <includes> 
    <include>**/*.js</include> 
    <include>**/[project.name].css</include> 
    </includes> 
    <excludes> 
    <exclude>**/depends/*.js</exclude> 
    </excludes> 
    </configuration> 
    </execution> 
    </executions> 
</plugin> 

注:我也嘗試了上面的jslint目標中的聚合配置,沒有喜悅。 (我知道YUI是一個壓縮插件,但它具有其他功能(如lint),所以我假設你可以關閉壓縮功能)。此外,Vaadin的@javascript註釋採用逗號分隔的js文件列表。我覺得加40會太方便,但也許@javascript有一個方法來建立一個目錄。 (文檔雖然沒有提到這一點)

回答

5

決定對這個問題我發現了一個解決方案,任何人發現它的一方,部分是因爲它沒有得到任何其他答案。

這個解決方案受到了這個answer的啓發,有人問了我需要的東西。 @Mady指出了不同的包括/在插件配置排除

短篇小說長,可以排除所有.js文件在minifyer 包括他們在agreegator:

<execution> 
    <id>minify</id> 
    <goals> 
    <goal>compress</goal> 
    </goals>      
    <configuration> 
    <nosuffix>true</nosuffix> 
    <force>true</force> 
    <excludeWarSourceDirectory>true</excludeWarSourceDirectory> 
    <linebreakpos>-1</linebreakpos> 
    <aggregations> 
     <aggregation> 
     <includes> 
      <include>**/*.js</include> <!-- INCLUDES FOR CONCATENATION --> 
     </includes> 
     </aggregation> 
    </aggregations> 
    <excludes> 
     <exclude>**/*.js</exclude> <!-- EXCLUDE ALL JS FROM MINIFICATION --> 
    </excludes> 
    </configuration> 
</execution>