Using Yui+ant to implement JS CSS compression _php instance

Source: Internet
Author: User
Tags echo message mkdir

Today, the study of Yui Yahoo Open source framework, feel very fierce ah.

So I did a Yui ant implementation, online a lot about the realization of bat, I have a way, out of this ant implementation, hehe unique article, if reproduced, its annotated author and website

Copyright:Mr.chen

All right, here are the details:

Website:

Yuicompressor-2.4.6.jar Download Address http://yuilibrary.com/downloads/

Yuiant.jar Download Address http://www.ubik-ingenierie.com/miscellanous/YUIAnt/

The specific relevant code is as follows:

#css work dir commoncss.dir = css #js work dir commonjs.dir = js #build temp dir output.temp.dir = Build #ou Tput files in the directory Output.dir = ${output.temp.dir}_output #environment needs lib Liblib = Lib <?xml ve Rsion= "1.0" encoding= "UTF-8"?> <project name= "Compress css-js" default= "Compress" basedir= "."  
      > <property file= "bulid.properties"/> <path id= "Yuiclasspath" > <fileset dir= "${lib}" > <include name= "*.*"/> </fileset> </path> <!--###################### #Init the E  Nvironment of the tool ##########################--> <target name= "init" > <echo message= "begin to Init 
    The init "/> <echo message=" deletes all reference files. "/> <delete dir=" ${output.dir} "/> <echo message= ' Delete End '/> <echo message= ' make the reference files./> <mkdir dir= IR} "/> <mkdir dir=" ${output.temp. Dir} "/> <echo message=" make end. "/> </target> <!--###################### #Combine the CS s files ##########################--> <target name= "combinecss" depends= "init" description= "Combine common CSS files "> <echo message=" begin to combine the CSS files to one file. "/> <concat destfile=" ${OUTPU T.temp.dir}/combined_css.css "encoding=" UTF-8 "append=" false "> <fileset dir=" ${commoncss.dir} "> & Lt;include name= "*.css"/> </fileset> </concat> <echo message= "combine end."/> & lt;/target> <!--###################### #Combine the JS files ##########################--> <targ ET name= "Combinejs" > <echo message= "begin to combine the JS files to one file."/> <concat destfile= 
        "${output.temp.dir}/all_source.js" encoding= "Utf-8" append= "false" > <fileset dir= "${commonjs.dir}" > <include name= "*.JS "/> </fileset> </concat> <echo message=" combine end. "/> </target> & lt;! --###################### #Compress the JS and CSS files ##########################--> <target name= "Compress" dep 
    ends= "Combinecss,combinejs" description= "Compress" > <echo message= "begin to Compress the CSS file."/> <taskdef name= "yuicompress" classname= "Com.yahoo.platform.yui.compressor.YUICompressTask" > <classpath > <path refid= "Yuiclasspath"/> </classpath> </taskdef> <!--metho D compress the CSS files--> <yuicompress linebreak= "10000000" warn= "false" munge= "Yes" preserveallsemicolons= " True ' outputfolder= ' ${output.dir} ' > <fileset dir= ' ${output.temp.dir} ' > <include name= ' *.css '/ > </fileset> </yuicompress> <echo message = "Compress the css end."/> <!--s Econd method Compress the JS files--> <echo message = "Begin to compress the JS file."/> <apply executable= "java" parallel= "F Alse "failonerror= true" > <fileset dir= "${output.temp.dir}" includes= "All_source.js"/> <arg Lin 
      E= "-jar"/> <arg path= "${lib}/yuicompressor-2.4.6.jar"/> <arg line= "--charset utf-8"/>  <arg line= "-o ${output.dir}/combined_js.js"/> <srcfile/> </apply> <echo Message = "Compress the JS end."/> <delete dir= "${output.temp.dir}"/> </target> </project> @e Cho off Echo ################################################ echo ######### #Tool Compress the JS and css########## Ech O ################################################ echo sure your CSS and JS in the CSS ' directory and JS ' dire 
Ctory. 
echo If sure,please Enter any button to continue the tool. Pause call Ant-buildfile Compress.xml compress>build.log echo Compress End pause  

 
  related files I provide download, feel good, leave a message

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.