minify-maven-plugin也缩小了html和xml文件

时间:2015-01-09 10:07:42

标签: javascript maven minify

 <plugin>
                    <groupId>com.samaxes.maven</groupId>
                    <artifactId>minify-maven-plugin</artifactId>
                    <version>1.7.2</version>
                    <executions>
                        <execution>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>minify</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <charset>UTF-8</charset>
                        <skipMerge>true</skipMerge>
                        <webappSourceDir>WebContent</webappSourceDir>
                        <cssSourceDir>/</cssSourceDir>
                        <jsSourceDir>/</jsSourceDir>
                        <nosuffix>false</nosuffix>

                        <webappTargetDir>${project.build.directory}/minify</webappTargetDir>
                        <cssSourceIncludes>
                            <cssSourceInclude>**</cssSourceInclude>
                        </cssSourceIncludes>
                        <cssSourceExcludes>
                            <cssSourceExclude>**/*.min.css</cssSourceExclude>
                        </cssSourceExcludes>
                        <jsSourceIncludes>
                            <jsSourceInclude>**</jsSourceInclude>
                        </jsSourceIncludes>
                        <jsSourceExcludes>
                            <jsSourceExclude>**/*.min.js</jsSourceExclude>
                        </jsSourceExcludes>
                    </configuration>
            </plugin>

我正在使用maven-minify-plugin来缩小js和css文件,并在pom.xml中添加了上面的代码。现在这样可以正常工作,但它会尝试将所有文​​件(包括xml和html文件)缩小。 如何停止缩小xml和html以及其他文件?

2 个答案:

答案 0 :(得分:0)

我举一个例子,说明如何在项目中仅缩小css。可能你的问题是关于像** / * ..

这样的路径

希望这会有所帮助:

<plugin>
            <groupId>com.samaxes.maven</groupId>
            <artifactId>minify-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>minify-css</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>minify</goal>
                    </goals>
                    <configuration>
                        <charset>utf-8</charset>
                        <jsEngine>closure</jsEngine>
                        <cssSourceDir>WEB-INF/assets/stylesheets</cssSourceDir>
                        <cssSourceFiles>
                            <cssSourceFile>jquery-ui.css</cssSourceFile>
                            <cssSourceFile>leaflet.css</cssSourceFile>
                            <cssSourceFile>app.css</cssSourceFile>
                        </cssSourceFiles>
                        <cssFinalFile>style.css</cssFinalFile>
                    </configuration>
                </execution>
          </executions>
     </plugin>

答案 1 :(得分:0)

@ Alien01,将行<cssSourceInclude>**</cssSourceInclude>更改为<cssSourceInclude>**/*.css</cssSourceInclude>,将<jsSourceInclude>**</jsSourceInclude>更改为<jsSourceInclude>**/*.js</jsSourceInclude>应修复它。
如果有效,请告诉我。