[英]not to minify the js when degugging the code minify-maven-plugin samaxes
[英]minify-maven-plugin (com.samaxes.maven v1.7.6) is not replacing the minified files with the original files
我想縮小 maven 項目中的 JS 和 CSS 文件。 我使用了 minify-maven-plugin (com.samaxes.maven v1.7.6)。 As per the documentation ( https://samaxes.github.io/minify-maven-plugin/minify-mojo.html ), I have set < nosuffix > and < skipMerge > as true because I want to maintain the file structure and replace帶有原始文件的縮小文件。 我還設置了< phase > package </ phase >。 生成並部署 WAR 文件后,JS 和 CSS 文件沒有被縮小,它們和以前一樣。 我還參考了一些 stackoverflow 答案,並根據https://stackoverflow.com/questions/22117824/using-samaxes-minify-nosuffix-to-overwrite-original-files提供的建議設置了 < warSourceExcludes > 選項< warSourceExcludes > 選項,當我在服務器上部署 WAR 文件時,JS 和 CSS 文件不可用,並且應用程序顯示相同的 404 錯誤。 請參考我的 pom.xml 配置:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<warSourceExcludes>**/*.css,**/*.js</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.6</version>
<executions>
<execution>
<id>default-minify</id>
<phase>package</phase>
<configuration>
<charset>UTF-8</charset>
<webappSourceDir>${project.basedir}/WebContent</webappSourceDir>
<cssSourceDir>./</cssSourceDir>
<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>
<cssSourceExcludes>
<cssSourceExclude>**/*.min.css</cssSourceExclude>
</cssSourceExcludes>
<jsSourceDir>./</jsSourceDir>
<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>
<jsSourceExcludes>
<jsSourceExclude>**/*.min.js</jsSourceExclude>
</jsSourceExcludes>
<jsEngine>CLOSURE</jsEngine>
<nosuffix>true</nosuffix>
<skipMerge>true</skipMerge>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
請提出適當的解決方案。 提前致謝 !
@Kristof Neirynck 對於如何讓 maven 使用 yuicompressor-maven-plugin 與縮小文件建立戰爭這一問題給出的答案適用於上述問題。 我將 < phase > 屬性更改為prepare-package並添加
<webappTargetDir>${project.build.directory}/minify</webappTargetDir>
在 < webappSourceDir > 之后的 minify -maven-plugin和maven-war-plugin中,我設置了以下配置:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<webResources>
<resource>
<directory>${project.build.directory}/minify</directory>
</resource>
</webResources>
</configuration>
</plugin>
使用此配置后,當我在 Tomcat 中部署 WAR 文件時,將原始文件替換為縮小文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.