如何使用Maven htmlcompressor插件怎么打包thymeleaf的HTML文件
时间: 2023-05-10 12:55:14 浏览: 299
你可以在pom.xml文件中添加以下依赖:
```
<dependency>
<groupId>com.googlecode.htmlcompressor</groupId>
<artifactId>htmlcompressor</artifactId>
<version>1.5.3</version>
</dependency>
```
然后在Maven插件中添加以下配置:
```
<plugin>
<groupId>com.googlecode.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<enabled>true</enabled>
<removeIntertagSpaces>true</removeIntertagSpaces>
<removeComments>true</removeComments>
<compressJavaScript>true</compressJavaScript>
<compressCss>true</compressCss>
<preserveLineBreaks>false</preserveLineBreaks>
<preservePatterns>
<pattern>
<!-- 保留thymeleaf的模板语法 -->
<regexp>\\$\\{.*?\\}</regexp>
<type>regex</type>
</pattern>
</preservePatterns>
</configuration>
</plugin>
```
这样配置后,运行Maven命令`mvn clean package`即可将thymeleaf的HTML文件进行压缩和打包。
阅读全文