2
回答
yuicompressor-maven-plugin过滤min文件问题
开发十年,就只剩下这套Java开发体系了   

我用maven插件yuicompressor-maven-plugin进行js和css的压缩

首先对已经是min的文件排除不压缩(如bootstrap.min.css),然后在maven-war-plugin中把js和css排除, 不覆盖压缩后的文件,但是,yuicompressor-maven-plugin中被排除掉的min的js和css也没有在最终的war包中

谁知道,怎么进行压缩的同时,把min文件也加入到最终war包里

pom文件如下:

<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
<excludes>
<exclude>**/*.min.js</exclude>
<exclude>**/*-min.js</exclude>
<exclude>**/*.min.css</exclude>
<exclude>**/*-min.css</exclude>
</excludes>
<encoding>utf8</encoding>
<failOnWarning>false</failOnWarning>
<force>true</force>
<nosuffix>true</nosuffix>
<linebreakpos>-1</linebreakpos>
<jswarn>false</jswarn>
<sourceDirectory>${basedir}/src/main/webapp/static</sourceDirectory>
</configuration>
</plugin>

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                    <configuration>
                        <warSourceExcludes>**/*.js,**/*.css</warSourceExcludes>
                    </configuration>
            </plugin>

举报
高达
发帖于3年前 2回/1K+阅
共有2个答案 最后回答: 2年前

加一个资源处理plugin就可以了:

<plugin>

<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-min</id>
<phase>process-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/static</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/webapp/static</directory>
<includes>
<include>**/*.min.js</include>
<include>**/*.min.css</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
顶部