yuicompressor-maven-plugin插件压缩js和css

  1. 工程结构

yuicompressor-maven-plugin插件压缩js和css

2. pom.xml部分配置

                        <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>
					<skip>false</skip>
					<encoding>UTF-8</encoding>
					<!-- 忽略 js 错误警告 -->
					<jswarn>true</jswarn>
					<force>false</force>
					<!-- 使用.min后缀 -->
					<!-- <suffix>.min</suffix> -->
					<nosuffix>true</nosuffix>
					<!-- 把文件压缩成一行 -->
					<linebreakpos>-1</linebreakpos>
					<statistics>true</statistics>
					<warSourceDirectory>${basedir}/WebRoot</warSourceDirectory>
					<includes>
						<include>**/**.js</include>
						<include>**/**.css</include>
					</includes>
					<excludes>
						<exclude>**/**min.js</exclude>
						<exclude>**/**min.css</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<!-- 生成的web目录 -->
					<warSourceDirectory>${basedir}/WebRoot</warSourceDirectory>
					<warSourceExcludes>**/*.js,**/*.css</warSourceExcludes>
				</configuration>
				<version>2.6</version>
			</plugin>

3. 执行

使用mvn clean package等命令即可压缩和打包。


你可能感兴趣的:(yuicompressor-maven-plugin插件压缩js和css)