【问题标题】:The yuicompressor-maven-plugin seems to be ignoring my in exclude/include optionyuicompressor-maven-plugin 似乎忽略了我的排除/包含选项
【发布时间】:2012-03-27 22:22:03
【问题描述】:

我的目标是仅压缩某些目录中的某些 javascript 文件,但该插件仍在遍历我的整个目录结构以尝试压缩所有 javascript 文件。这是我的 pom 的样子:

<plugin>
    <groupId>net.alchim31.maven</groupId>
     <artifactId>yuicompressor-maven-plugin</artifactId>
     <version>1.3.0</version>
     <executions>
       <execution>
          <phase>compile</phase>
          <goals>
              <goal>compress</goal>
          </goals>
       </execution>
     </executions>
     <configuration>
       <nosuffix>true</nosuffix>
       <aggregations>
         <aggregation>
            <insertNewLine>true</insertNewLine>  
            <output>${project.build.directory}/${project.build.finalName}/js/analytics/all.js</output>
            <inputDir>${basedir}/src/main/webapp/js/analytics/app</inputDir>
          <includes>        
             <include>${basedir}/src/main/webapp/js/analytics/app/application.js</include>
          </includes>
          <excludes>
            <exclude>all-js-min.js</exclude>
          </excludes>
        </aggregation>
     </aggregations>
   </configuration>
  </plugin>

我希望它只会查找位于 ${basedir}/src/main/webapp/js/analytics/app 中的 js 文件并且只压缩 application.js,因为这是我专门针对的唯一文件包括。它还尝试压缩 all-js-min.js。
似乎包含/排除选项被忽略了。任何想法可能出了什么问题?

【问题讨论】:

    标签: javascript maven yui-compressor


    【解决方案1】:

    顶层配置有一个“排除”选项。试试这个:

    <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>yuicompressor-maven-plugin</artifactId>
        <version>1.3.0</version>
        <executions>
            <execution>
                <goals>              
                    <goal>compress</goal>
                </goals>
                <phase>process-sources</phase>
            </execution>
        </executions>
        <configuration>
            <excludes>
                <exclude>[what you want to exclude]</exclude> 
            </excludes>
            <aggregations>
                <aggregation>
                    <removeIncluded>false</removeIncluded>
                    <includes>
                        <include>**/[js file name to include 1]</include>
                        <include>**/[js file name to include 2]</include>
                    </includes>
                    <output>[js file minified]</output>
                </aggregation>
            </aggregations>
        </configuration>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2016-10-31
      • 2017-01-02
      • 2018-05-15
      • 2018-10-11
      • 2013-06-01
      • 2011-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多