yuicompressor-maven-plugin插件壓縮js和css

  1. 工程結構css

2. pom.xml部分配置web

                        <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. 執行apache

使用mvn clean package等命令便可壓縮和打包。maven

相關文章
相關標籤/搜索