若依集成yuicompressor实现(CSS/JS压缩)

柔光的暖阳◎ 2023-10-03 19:48 115阅读 0赞

Maven打包的时候可以使用YUI Compressor(压缩CSS/JS)文件,使用yuicompressor-maven-plugin插件进行压缩后会减小体积,提高请求速度。

pom.xml文件中增加该插件的定义,示例如下:

  1. <build>
  2. <plugins>
  3. <!-- YUI Compressor (CSS/JS压缩) -->
  4. <plugin>
  5. <groupId>net.alchim31.maven</groupId>
  6. <artifactId>yuicompressor-maven-plugin</artifactId>
  7. <version>1.5.1</version>
  8. <executions>
  9. <execution>
  10. <phase>prepare-package</phase>
  11. <goals>
  12. <goal>compress</goal>
  13. </goals>
  14. </execution>
  15. </executions>
  16. <configuration>
  17. <!-- 读取js,css文件采用UTF-8编码 -->
  18. <encoding>UTF-8</encoding>
  19. <!-- 是否忽略警告 -->
  20. <jswarn>false</jswarn>
  21. <!-- 是否添加.min后缀 -->
  22. <nosuffix>true</nosuffix>

发表评论

表情:
评论列表 (有 0 条评论,115人围观)

还没有评论,来说两句吧...

相关阅读