使用YUI+Ant 实现JS CSS压缩
网络编程 2021-07-05 09:50www.168986.cn编程入门
YUI库是一组工具和控件,它们用JavaScript写成, 为的是用DOM 脚本,DHTML和AJAX等技术创建丰富的网页交互式应用程序。YUI 基于BSD协议,对所有的使用方式都是免费的。YUI 项目包括YUI 库和两个创建时工具YUI Compressor (压缩)和YUI Doc(JavaScripts代码的文档引擎)
今天研究了一下YUI yahoo开源框架,感觉很猛啊。
于是乎我做了一个YUI的ant实现,网上好多关于bat的实现,我就另辟蹊径,出个关于这个的ant实现,嘿嘿独一无二的文章,如果网络推广网站推广转载的话,其注明作者和网站
copyrightMr.chen
好了具体操作如下
官网:
yuipressor-2.4.6.jar 下载地址
YUIAnt.jar 下载地址
具体的相关代码如下
#css work dir monCss.dir = css #js work dir monJs.dir = js #build temp dir output.temp.dir = build #output files in the directory output.dir = ${output.temp.dir}_output #environment needs lib liblib = lib <?xml version="1.0" encoding="UTF-8"?> <project name="Compress CSS-JS" default="press" basedir="."> <property file="bulid.properties" /> <path id="yuiClasspath"> <fileset dir="${lib}"> <include name="." /> </fileset> </path> <!-- #######################Init the environment of the tool ##########################--> <target name="init"> <echo message="begin to init the init" /> <echo message="delete all reference files." /> <delete dir="${output.dir}" /> <echo message="delete end" /> <echo message="make the reference files." /> <mkdir dir="${output.dir}" /> <mkdir dir="${output.temp.dir}" /> <echo message="make end." /> </target> <!-- #######################Combine the css files ##########################--> <target name="binecss" depends="init" description="Combine mon css files"> <echo message="begin to bine the css files to one file." /> <concat destfile="${output.temp.dir}/bined_css.css" encoding="UTF-8" append="false"> <fileset dir="${monCss.dir}"> <include name=".css" /> </fileset> </concat> <echo message="bine end." /> </target> <!-- #######################Combine the js files ##########################--> <target name="binejs"> <echo message="begin to bine the js files to one file." /> <concat destfile="${output.temp.dir}/all_source.js" encoding="utf-8" append="false"> <fileset dir="${monJs.dir}"> <include name=".js" /> </fileset> </concat> <echo message="bine end." /> </target> <!-- #######################Compress the js and css files ##########################--> <target name="press" depends="binecss,binejs" description="Compress"> <echo message="begin to press the css file." /> <taskdef name="yuipress" classname=".yahoo.platform.yui.pressor.YUICompressTask"> <classpath> <path refid="yuiClasspath" /> </classpath> </taskdef> <!-- first method press the css files --> <yuipress linebreak="10000000" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${output.dir}"> <fileset dir="${output.temp.dir}"> <include name=".css" /> </fileset> </yuipress> <echo message ="press the css end." /> <!-- second method press the js files--> <echo message ="begin to press the js file." /> <apply executable="java" parallel="false" failonerror="true"> <fileset dir="${output.temp.dir}" includes="all_source.js" /> <arg line="-jar" /> <arg path="${lib}/yuipressor-2.4.6.jar" /> <arg line="--charset utf-8" /> <arg line="-o ${output.dir}/bined_js.js" /> <srcfile /> </apply> <echo message ="press the js end." /> <delete dir="${output.temp.dir}" /> </target> </project> @echo off echo ################################################ echo ##########Tool Compress the js and css########## echo ################################################ echo Please make sure your css and js in the css'directory and js'directory. echo If sure,please enter any button to continue the tool. pause call ant -buildfile press.xml press>build.log echo press end pause
相关的文件我提供下载,感觉好的,就留言吧
编程语言
- 宿迁百度关键词排名指南:实现精准营销的关键
- 四川SEO优化怎么做网络推广
- 立昂技术备案老域名收购:如何为您的业务赋能
- 安徽百度关键词seo贵不贵,一般需要多少钱
- 吉林百度快照排名怎么做电话营销
- 多伦新手做SEO怎么做
- 甘肃优化关键词排名推广怎么做论坛营销
- 沙雅SEO网站推广:提升您的在线可见性
- 四川SEO优化如何提升销售额和销售量
- 聂荣网站排名优化:提升网站可见性的全方位指
- 涞水SEO:提升地方企业在线可见性的策略
- 辽宁百度seo排名怎样做网站排名
- 临湘哪有关键词排名优化:提升网站可见度的关
- 黑龙江百度网站优化有没有优惠
- 凉城优化关键词排名推广:提升您的网络可见性
- 萝北整站优化:提升您网站流量和排名的全面指