toxic

备忘录

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.准备工作

 安装binary apache ant ,安装JDK ,下载yui-compress.jar 

 

2.压缩

进入要压缩JS的工作目录

huandeMacBook-Pro:mjgame_website_php_www_web_js shameless$ pwd
/Users/shameless/php_workspace/backup/mjgame_website_php_www_web_js

 

 

目录结构

huandeMacBook-Pro:mjgame_website_php_www_web_js shameless$ ls
My97DatePicker        common            index.js        prepare_pay.js        store.js
app.js            forget_pwd_1.js        introduce.js        rank.js            user_message.js
build            forget_pwd_3.js        lottery.js        service.js        userinfo.js
build.xml        game_login.js        navigator.js        signup.js        yuicompressor-2.4.8.jar

 

build.xml

<?xml version="1.0" encoding="UTF-8"?>

<project name="newbee" default="compress" basedir=".">
        <description>Build file for Ant</description>
        <property name="newbee_js" location="."/>
        <property name="build" location="build"/>
        <property name="inputencoding" value="utf-8" />
        <property name="outputencoding" value="utf-8" />
        
        
        <target name="init">
            <mkdir dir="${build}" />
            <mkdir dir="${build}/common" />
        </target>
        
        <target name="multi">
             <antcall target="app"></antcall>
             <antcall target="forget_pwd_1"></antcall>
             <antcall target="forget_pwd_3"></antcall>
             <antcall target="game_login"></antcall>
             <antcall target="index"></antcall>
             <antcall target="introduce"></antcall>
             <antcall target="lottery"></antcall>
             <antcall target="navigator"></antcall>
             <antcall target="prepare_pay"></antcall>
             <antcall target="rank"></antcall>
             <antcall target="service"></antcall>
             <antcall target="signup"></antcall>
             <antcall target="store"></antcall>
             <antcall target="user_message"></antcall>
             <antcall target="userinfo"></antcall>
             <antcall target="jquery_ext"></antcall>
             <antcall target="mydialog"></antcall>
         </target>
        
        <target name="app">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 app.js -o ${build}/app.js"/>
           </java>
        </target>
        
        <target name="forget_pwd_1">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 forget_pwd_1.js -o ${build}/forget_pwd_1.js"/>
           </java>
        </target>
        
        
        <target name="forget_pwd_3">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 forget_pwd_3.js -o ${build}/forget_pwd_3.js"/>
           </java>
        </target>
        
        
        <target name="game_login">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 game_login.js -o ${build}/game_login.js"/>
           </java>
        </target>
        
        
        <target name="index">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 index.js -o ${build}/index.js"/>
           </java>
        </target>
        
        
        <target name="introduce">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 introduce.js -o ${build}/introduce.js"/>
           </java>
        </target>
        
        
        <target name="lottery">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 lottery.js -o ${build}/lottery.js"/>
           </java>
        </target>
        
        
        <target name="navigator">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 navigator.js -o ${build}/navigator.js"/>
           </java>
        </target>
        
        
        <target name="prepare_pay">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 prepare_pay.js -o ${build}/prepare_pay.js"/>
           </java>
        </target>
        
        
        <target name="rank">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 rank.js -o ${build}/rank.js"/>
           </java>
        </target>
        
        
        <target name="service">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 service.js -o ${build}/service.js"/>
           </java>
        </target>
        
        
        <target name="signup">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 signup.js -o ${build}/signup.js"/>
           </java>
        </target>
        
        <target name="store">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 store.js -o ${build}/store.js"/>
           </java>
        </target>
        
        
        <target name="user_message">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 user_message.js -o ${build}/user_message.js"/>
           </java>
        </target>
        
        <target name="userinfo">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 userinfo.js -o ${build}/userinfo.js"/>
           </java>
        </target>
        
        
        <target name="jquery_ext">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 common/jquery.ext.js -o ${build}/common/jquery.ext.js"/>
           </java>
        </target>
        
        
        <target name="mydialog">
           <java jar="yuicompressor-2.4.8.jar" fork="true">
                  <arg line="--type js --charset utf-8 common/mydialog.js -o ${build}/common/mydialog.js"/>
           </java>
        </target>
        
        
</project>        

 

使用 :

1.先运行 "ant init" 来生成文件夹

2.运行"ant multi" 生成压缩的js文件

 

posted on 2014-10-27 15:33  toxic  阅读(325)  评论(0编辑  收藏  举报