【问题标题】:How to exclude a folder from YUI compressor如何从 YUI 压缩器中排除文件夹
【发布时间】:2016-03-01 06:21:33
【问题描述】:

我想排除包含一组 javascript 文件的文件夹,YUI 压缩器不会编译和抽出错误。我正在尝试使用 <exclude>folder</exclude> 标签,但它不起作用 - YUI 仍在尝试压缩文件夹中的文件。

以下是我的 pom 配置:

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>1.5.1</version>
    <executions>
        <execution>
            <id>compressyui</id>
                <phase>process-resources</phase>
                <goals>
                    <goal>compress</goal>
                </goals>
                <configuration>
                    <nosuffix>true</nosuffix>
                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    <jswarn>false</jswarn>
                    <sourceDirectory>src/main/webapp/js-max</sourceDirectory>
                    <webappDirectory>src/main/webapp</webappDirectory>
                    <outputDirectory>src/main/webapp/js</outputDirectory>
                    <force>true</force>
                    <excludes>
                          <!-- yuicompressor fails to compile patterns library, hence stopping full build -->
                          <!-- We won't be modifying this library so will exclude it for now -->
                          <exclude>src/main/webapp/js-max/patterns/*</exclude>
                    </excludes>
                </configuration>
        </execution>
    </executions>
</plugin>

知道如何做到这一点吗?

【问题讨论】:

  • 在那个帖子中抢夺:stackoverflow.com/questions/11836599/…
  • @Tunaki 谢谢老兄,我找到了解决办法 :)
  • 嗨,@Tunaki 这个插件将压缩 src/main/webapp 下的所有 .js 和 .css 文件。但就我而言,我的 .js 和 .css 文件位于 src/main/resources/static 下,那么如何将默认路径更改为此?提前致谢。
  • 嗨,@JoelMin 这个插件将压缩 src/main/webapp 下的所有 .js 和 .css 文件。但就我而言,我的 .js 和 .css 文件位于 src/main/resources/static 下,那么如何将默认路径更改为此?提前致谢。

标签: javascript eclipse maven minify yui-compressor


【解决方案1】:

找到了解决方案,我在这里发帖,让每个人都可以看到。就我而言,以下方法有效:

我不得不使用&lt;exclude&gt;**/patterns/*&lt;/exclude&gt;,而不是&lt;exclude&gt;src/main/webapp/js-max/patterns/*&lt;/exclude&gt;。所以以下是对我有用的完整 pom 配置:

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>1.5.1</version>
    <executions>
        <execution>
            <id>compressyui</id>
            <phase>process-resources</phase>
            <goals>
                <goal>compress</goal>
            </goals>
            <configuration>
                <nosuffix>true</nosuffix>
                <warSourceDirectory>src/main/webapp</warSourceDirectory>
                <jswarn>false</jswarn>
                <sourceDirectory>src/main/webapp/js-max</sourceDirectory>
                <webappDirectory>src/main/webapp</webappDirectory>
                <outputDirectory>src/main/webapp/js</outputDirectory>
                <force>true</force>
                <excludes>
                      <!-- yuicompressor fails to compile patterns library, hence stopping full build -->
                      <!-- We won't be modifying this library so will exclude it for now -->
                      <exclude>**/patterns/*</exclude>
                </excludes>
            </configuration>
    </execution>
</executions>

【讨论】:

  • 嗨,@JoelMin 是您的 js、css 文件所在的位置,对吗?如果我将此路径更改为 'src/main/resources/static' 也会起作用。实际上我在上述文件夹中有我的 jss 和 css 文件。提前致谢。
猜你喜欢
  • 1970-01-01
  • 2021-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-17
  • 2011-09-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多