JS代码和CSS代码在上线前要压缩大家应该都是知道的了。记得之前做项目的时候,最后要交差的时候是找了个网站,将JS代码的文件一个一个地复制,粘贴,复制,粘贴。
当时就在想:TMD有没有好一点的方法,劳资不想老是用Ctrl大法。啊啊啊啊啊啊啊啊阿~。最最坑爹的是,有时候将代码复制粘贴的时候手一抖可能就删了点什么东西,手一快又保存了,反正各种坑爹。坑到没朋友。
但是呢,不压缩也不是是吧?
在写JS代码渐渐多了起来的时候就发现手动压缩根本不是长远的方法。而且JS的代码也开始分块,分功能,分文件写了,尽量去做到复用。
在实际项目中,推荐的是一个html对应一个JS文件和一个CSS文件。这样做可以减少HTTP请求,众所周知,一个HTTP请求的延迟远比下载一个大点的文件大得多。
所以从
程序员来看:我要分文件,分模块写。不然代码太混乱了。(多文件)
客户(网站的使用者)来看:我要良好的用户体验,越快越好。(少文件,文件一多HTTP请求会很多)
这就产生了冲突,不过有需求就有市场,我们聪明的前端攻城狮也有自己的方法解决。——链接文件与压缩大法,也就是标题“使用Ant和YUICompressor链接合并压缩你的JS和CSS代码”。
Ant,中文翻译过来就是“蚂蚁”。嗯嗯这是Apache的一个项目,基于Java的build工具,可以将一些项目的代码文件合并或者复制。具体的东东可以自行Google或者Baidu
YUICompressor,雅虎公司的一个代码压缩工具,貌似压缩比例也挺高的。网上一搜一堆的在线压缩网站有的也是这个做得。也是基于Java的。
这两个都是比较简单基本的合并压缩工具了
第一步:配Java环境
这一步就跳过吧,这么简单是吧?Ant和YUICompressor都是基于Java来做得,不懂得自行Google或者Baidu,这里说的是环境变量那里的配置。不是Eclipse里面的。嗯我知道你们想到了-_-!!。估计很多都配过了就不多说了。
第二步:创建项目
Eclipse下创建一个新的项目,Dynamic Web Project。打开Project Explorer窗口(window->show View)
如图所示,我建立了一个AntTest项目,然后在WebContent下面建立了三个文件夹,
- build 这个文件夹是用来放链接合并和压缩工具的
- build_output 这个文件夹是用来放项目上线的前端代码和页面的
- web 这个是用来放一些代码的各个未链接压缩的部分的,平常编辑代码的话就在这个文件夹下面编辑和修改
第三步:创建具体文件
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQgAAAJ9CAIAAABGk3tHAAAgAElEQVR4nO2d7W8c1b3H9+/oy7666oN6uTwkbCGNTKGATJJS9UWliqpUmhYJiVAnbBMb3JvYxARys0lI0gqQnYQYSAwFNywqNLWqJIWGBwUrSSs2xEmgOA/eEBxizz44577Yhzkz8zszs2dnd86c+X40snbHc2bO7M5n58zO+e5JsZBIpVJhrUoz8MrEEbxnABCEJkZ0n4v5bDpl5CLaeABwxogjIb9nc4XPjm5/4PDGZYc3Lju6/YG5wmcBC+aMFH9057PpVDqbFzy14y1GzkjVUdkeoBheYly/ft13jrWiVIox9veNy+dn8gvzlxbmL3117sN3n30gaEVyBnfo57PpVIp7bvunE7EYOcOmQ84Qr0SE3OnIVgpnjDgifM+Gh4czmUy5XG7MKZfLmUxmZGREVGRuZurQ4KIvjvR+Ofnk1cmBKx/0f/HX1R8/99P3t3W/v6372PAvil/PCCtiOynkjJRhGI1jK59NexzSomPXcRKSIwQxQByhxahUKplMZunSpQ03qlZU51QqFWJFqdQ/Nt11/thzVz7dNzs1Njs1Nnt6/5X8vi/zr3w19fpXU6/PnNxzdPv94ppwB1POSBk567ntMLOaRnVXqv+25lsrEdrEta9sa05nswa3cm6x2qrcW/cvhTNGHBG+Z6VSqWHC3NycwxOSd5640byQ85jeeeJGj6o0jv9c9VzROE/kDOpgbyxebXfVj+/GeUIoRs5wtNJqZbmGl3X64qUkt+5bCsQSrw+zxlmiu7vb14pUKvVW7w3m5/ur07Wpvfm3Hj36/IpDW7oObek6lO06lO3629Cth7fec3jrPYe33kusomZCQ4jaA+t45D/orU9kx1FYfyoSwzmfP8T54951iNNb9yuFM0Y88XnP+BaUhxVVxjPfM8+MmGdGLn+8+ciOey58tMWcfsOcHjenx83zfzbPHzDPv2leyF3+9+6DTy2lVlBvQnHNFOdz4lgXiCEygxCjcWLyE4NYn78YII74f5iVy+Vdu3aVSiWfF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HzqIAUDoQAwACCAGAAQQAwACiAEAAcQAgABiAEAAMQAgaKMYTf2E+Fzhs6PbHzi8cdnhjcuObn9grvBZwIK2sUlcyYj6U67zOBc6sg2FJU5oOzsTOha1/m3fimI/3w2aol1iNDvoxN83Lp+fyS/MX1qYv/TVuQ/fffaBoFsi0hPWc74HubtHnqPvXoAfI89n0ynDEIyspeAoD0CWtojR7DBFczNThwYXfXGk98vJJ69ODlz5oP+Lv67++Lmfvr+t+/1t3ceGf1H8ekZY2HaOyBkpw7B6pZL9vS3IQUXdOMXI2U9LEENH2nXGaGpgu39suuv8seeufLpvdmpsdmps9vT+K/l9X+Zf+Wrq9a+mXp85uefo9vvFpe3DVFUPW3dI1UcMr2OaWIwflQti6EgbrzGCu/HOEzeaF3Ie0ztP3OhRnB9VtHbUOhMN9ta/e0C5Zq4xLNWcY5natoJLjFjT3m+lAg6e/VbvDebn+6vTtam9+bcePfr8ikNbug5t6TqU7TqU7frb0K2Ht95zeOs9h7dScbyaCXzDyREF8m9KcRcZDV+ssUep9dTVwBlDR5Q4Y4xnvmeeGTHPjFz+ePORHfdc+GiLOf2GOT1uTo+b5/9snj9gnn/TvJC7/O/dB58ifz2t3oSy/fIMn8MOIIb4twOFglXVMCCGhihxjfFaz3fNU9sLHwxObOoqHNtsnt1tnt1tnt1jnnvRPLfXPDdqfvZSYfLZtzfeOTP1EbmG6kW37ePf9rypM4bHYvRA7RBDP5T4VuqVld+Zebf3naEfzBxdZ+a3mfltZv5Z89R289QO89RO89M/zHywITfYden0h8JVcD/jRD133Mfgxmd3X3lQ6xY3ycifEgGxR4n7GHsf/tab/YsuHVltnlhvnhgwTwyaJ580T24wTw6Z/3rq4pG1BwZ+ePFTsRUAhI0Sd74//NOmPQ9/e9+qG/Y/dtPY7255dc3i19Ysfm3N4lfXLH5z4Ef/HO299uV0++oJgBv0lQKAAGIAQAAxACD4fzV0kbtABz7EAAAAAElFTkSuQmCC" alt="" />
这张图是web文件夹下面的具体的文件模块,其实jQuery有一些模块没用到的话可以拆开加载的。也可以用这种方式加载进去
web/src/main.html文件的结构:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- asset为项目上线的代码 ,src为源码,可以看的-->
<link rel="stylesheet" type="text/css" href="./asset/css/all.css" />
</head>
<body>
<div id="MainContent">
<!--页面内容-->
<p>ANT测试页面</p>
</div>
<script type="text/javascript" src="./asset/js/all.js"></script>
</body>
</html>
这里的<link>链接到了一个all.css文件,一个<script>链接到了一个all.js文件,然后呢,我用用all.css和all.js再去链接到全部的css文件和js文件
这里两个all文件只是起来集合,或者说是链接的功能。
这里用到了 ./ 这个东西,表示当前路径下面,去掉这个也可以,还有一个 ../ 表示上一级目录,/ 是表示项目根目录的
web/asset/css/all.css:
@import '../../src/css/jquery.ui.core.css'; /*UI*/
@import '../../src/css/jquery.ui.button.css';
@import '../../src/css/jquery.ui.dialog.css';
@import '../../src/css/jquery.ui.accordion.css';
@import '../../src/css/jquery.ui.autocomplete.css';
这里是用到了import去链接CSS文件,当然我们做开发是可以这样玩的。但是最后的合并的文件肯定不会是用import方式的,而是一个或几个比较大的文件。
这里的路径是以all.css文件为起始点去web/src/css文件里面链接的,切记切记!
web/asset/js/all.js:
/*Base*/
document.write('<script type="text/javascript" src="../web/src/js/jquery-1.5.1.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.core.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.widget.js"></script>'); /*UI*/
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.draggable.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.droppable.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.button.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.dialog.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.accordion.js"></script>');
document.write('<script type="text/javascript" src="../web/src/js/jquery.ui.autocomplete.js"></script>');
JS代码是通过document.write方式输出到页面然后去加载的。这里因为all.js文件是被main.html执行了,然后main.html根据all.js输出的这些文件去加载的,所以这里的路径是相对于main.html文件的路径。
然后我们运行一下main.html测试一下路径有没有错(这里可以检验一下上面做得是否正确,如果不能加载表示文件路径放错了)
这里可以看到,全部文件都加载了进来。这样就OK了,下面继续链接合并与压缩大计。
第四步:放置工具文件到build文件夹里面
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPUAAADTCAIAAADWJsIZAAAS1UlEQVR4nO2d7U8cxx3H78+pmlZVlKqhJ7Vxt00jty6tKuWtK/XFqpUitVbrUErrtA04Z1zkswH3IY7sYPuq2IQkxFxwbAe1h+OEgIsJ4MQHAZvagDkMxgaGO2D64p5md2Yf7nb3bpn9frRCd8vO7ur43DC3O9/7hagNMtv04HTm+U83Dk5nMtsWG3f95qtkon1xsKmvRVkcPkJud5DbHeT2aXLnDLlzltyJkZl/LY60vd/8bGrqOtc6GQ2HQmpc/yQZDYfC0SS/MrtpXC0+0LbONQIBJWS5xWYpclNK3/j1V1LXGi5FnkkN/IUkW0mylSTbyEQ7mThOJv5GJv+eGnwl3qQsfDEkap2MhkOqqoZy5F3N2RoKhUJhVQ0b+p01PLdhNKrC74Bj7Tel9Nz8pk25KaVnX/hyz0tPL1zdT8ZeJmONZKyJjB8k46+Q8Qi5eej+1d9faPze/Umh3AC4jC2/KaX23KaU0qG3Wk6/8MS53z55/sWvd/7uG2/W13TV13TV17xZX9PT+NzHsYbVpdnyzhWAUrHrNwA7EfgNZAZ+A5mB30BmXPY7FArhp8lPUGHwogOZ8aT/Bjx4ZaoCXnQgM9L038Wb9f4E/XdV8ORFX1ucGWjf299c299cO9C+d21xxmZDdnoU1cyqEjzVYu53cVaKr98EwG2s/d7e1t+b59cUdxcKUUr/3fzj9VRya31ha33h4Z2ha2177Z5OnJ0RlZ1SVXweN5suZex3XNVYHVdLn3NV3j8HTSv031XB4kU/efJkXV1dJpMprMlkMnV1dadOnTJqspaaSjQ9fe9qw9LIwUcj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ifJ5HeYWeF8RbTyxt8odbkjkCV/SQtCs6MRTR1MO+MTZgCOUpcy4KP+21n+khbHJUwuTfPcjt/G1YpR6nIn4qPxt8P8Jc1/rtR0xprnJfXfJpuh1OWOwUfXT5zmL2luTKGr06rvabmxsfb7IwzNRKnLnYiPrn8jfwlcx0f3L5G/BK6D+SdAZuA3kBn4DWQGfgOZgd9AZuA3kBlDv/87nGi70PKrd99tu9Dy3+EEpfTEmbcePV7Vbfalnx/39gQBcMD/AVrYKtfxZi7WAAAAAElFTkSuQmCC" alt="" />
这是Ant和YUICompressor的文件夹。直接解压放里面就可以。
Ant的话也要配环境的,比如下面的
ANT_HOME D:/ apache-ant-1.9.0
path D:/ apache-ant-1.9.0/bin
classpath D:/apache-ant-1.9.0/lib
具体的路径放的不一样每台电脑都不同,可以看http://jingyan.baidu.com/article/e2284b2b45d193e2e6118dc6.html或者自行解决。
第五步:设置配置文件build.xml
我们这里是用
<?xml version="1.0" encoding="UTF-8"?> <project default="compress" basedir="D:\eclipseWorkSpace\AntTest\WebContent\web" name="core">
<!-- 项目的 web 路径,也就是我们修改代码的那个web文件夹的路径 -->
<property name="path" value="D:\eclipseWorkSpace\AntTest\WebContent\web" />
<!-- 部署的输出路径 也就是项目的链接合并压缩的输出文件夹的路径-->
<property name="targetDir" value="D:\eclipseWorkSpace\AntTest\WebContent\build_output\asset" />
<!-- 源文件路径(src) -->
<property name="code.src" value="src" />
<property name="baseService" value="baseService" />
<!-- !!! YUI Compressor 路径 !!! -->
<property name="yuicompressor" value="D:\eclipseWorkSpace\AntTest\WebContent\build\yuicompressor-2.4.6\yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar"/> <!-- =================================
target: concat 拼接(合并)文件
================================= --> <target name="concat" depends="" description="concat code">
<echo message="Concat Code Files Begin!!!" />
<!-- 需要注意这里的拼接顺序depends是优先链接合并的文件,也就是依赖的意思 --><!-- JS -->
<concat destfile="${targetDir}/js/source/all.js" encoding="utf-8" fixlastline="on">
<fileset dir="${code.src}/js" includes="jquery-1.5.1.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.core.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.widget.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.draggable.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.droppable.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.button.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.dialog.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.accordion.js" />
<fileset dir="${code.src}/js" includes="jquery.ui.autocomplete.js" />
</concat>
<!-- CSS -->
<concat destfile="${targetDir}/css/source/all.css" encoding="utf-8">
<fileset dir="${code.src}/css" includes="jquery.ui.core.css" />
<fileset dir="${code.src}/css" includes="jquery.ui.button.css" />
<fileset dir="${code.src}/css" includes="jquery.ui.dialog.css" />
<fileset dir="${code.src}/css" includes="jquery.ui.accordion.css" />
<fileset dir="${code.src}/css" includes="jquery.ui.autocomplete.css" />
</concat> <echo message="Concat Code Files Finished!!!" />
</target> <!-- =================================
target: copy 拷贝文件
================================= --> <target name="copy_asset" depends="concat" description="copy the asset file">
<echo message="Copy Asset Begin" />
<!-- main.html -->
<copy todir="${targetDir}/../" overwrite="true">
<fileset dir="${path}/" includes="*.html"/>
</copy>
<!-- img *.png -->
<copy todir="${targetDir}/img" overwrite="true">
<fileset dir="${path}/asset/img" includes="*.png" />
</copy> <echo message="Copy Asset Finished" />
</target> <!-- =================================
target: compress 压缩 js && css
================================= --> <target name="compress" depends="copy_asset" description="compress code">
<echo message="Compress Code Begin" /> <apply executable="java" parallel="false" failonerror="true" dest="${targetDir}/js">
<fileset dir="${targetDir}/js/source" includes="*.js"/>
<arg line="-jar"/>
<arg path="${yuicompressor}" />
<arg line="--charset utf-8" />
<arg line="-o" />
<targetfile/>
<mapper type="glob" from="*.js" to="*.js" />
</apply> <apply executable="java" parallel="false" failonerror="true" dest="${targetDir}/css">
<fileset dir="${targetDir}/css/source" includes="*.css"/>
<arg line="-jar"/>
<arg path="${yuicompressor}" />
<arg line="--charset utf-8" />
<arg line="-o" />
<targetfile/>
<mapper type="glob" from="*.css" to="*.css" />
</apply> <echo message="Compress Code Finished" /> <echo message="Clean Begin" /> <!--<delete verbose="false" failonerror="true">
<fileset dir="${path}" includes="${targetDir}/*-o.js" />
</delete> --> <echo message="Clean Finished" /> </target>
</project>
在命令提示符(CMD)下用ant的指令运行(别告诉我你不会。。。。。),学过Java的应该都懂的,javac嘛,一个道理:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoIAAAHACAIAAAC56p64AAAgAElEQVR4nO3dXZqjOJCFYZYxy5zNzT0767noLhdGEaETkkACf+9FPbYsQoGwOZlZf9v//O//bQAA4Hb//PPPRgwDADAFMQwAwDTEMAAA0xDDAABMQwwDADANMQwAwDTEMAAA0xDDAABMQwwDADANMQwAwDTEMAAA0xDDAABMQwwDADANMQwAwDTEMAAA0xDDAABMQwwDADANMQwAwDTtMbzv++hmuqzWDwAAVV8xvH+rHlzOOR2rlxri0Un86OYBAG3+xvApBtpiuK3OKPesNfALi1Opatk7v6YBANyAGG5cYmASB0+r8wEAj/ZfDDd/H2b+XDqecKmrlxtev7qB8at8fwwAj3ZrDHu/91wOHp/G8+PU3y3lq+VpiovqfQZdbQV9vlcBAPAIagx7ygO9XMyOb98Zo8yP+zk9OC1kLqrUz/apFGyYDwB4ot4Y3uRcrOZN+VT5TlEvGASbnrt6Sz0xnP06AADwUPfF8Ob8kHYveKXiOtUGzAd7+J1x9Wk8aJ5XtWBDAwCAh+r6k9LmZLGOF0vZHvTvJk8PvJ4HxrDVb7o+MQwAL2bHsBkGYl5WvxkVx8024vlxES+GT6d2UQyb5xsvXZ1vjgAAHsT+V7TKeXoMH+uUEWIuUY6Lk72WyjrHU6g+CA7X+/T2IejKPBdv/vEl70AAwOKG/dcOq4XBav0AAFAihgEAmIb/6BAAgGmIYQAApiGGAQCYhhgGAGAaYhgAgGmIYQAApiGGAQCYhhgGAGAaYhgAgGmIYQAApiG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ciSon+o/tc/VhQDglz0vhr37eHMM3BzDx5FULnr19RjOthevG7dBDAOAYukYPvFmmuMrxLDZ/3YI4CExrPejP/0Mms2bB4rXixgGgKOlY1icaY6PjeFqnbb+F49hc4K4z80LAcBPeUwMV9PrzhhWilT7Eb/LVPpRXu38MqJ5n0/nSAwDwNG6Mbw5PxQ9vZR66q2iN1kW2b8p/X9GTg+8/sVOgn6Cp17/2TrV8z2dMgBgWyqGq9nz9BUBADhZJYYBAPhBxDAAANP8888//w/IdNBsHRwKUwAAAABJRU5ErkJggg==" alt="" />
其实到这里大概流程就差不多了,但是呢,懒人总有偷懒的方法,上面还要打命令提示符,啊啊啊啊啊啊啊啊~
然后,自己做了个简单的批处理文件。
第六步:创建build.bat批处理文件自动执行ant指令
鼠标右键新建一个txt文件,然后打入
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAABECAIAAACar+kaAAAB70lEQVR4nO2cW3qDIBBGWXZ2mm10B+lTLZdhGDSV0P+czwdBFOPRAVGTvkCSlB5PJsUpPZ4v0APxoiBeFMSLgnhRavHph1U7BPdQiM99n3Z/53nTq4tzd4gh/jhqV9y/ZeeCtVTV9fIh51d8Lnsv8Utq352o+JTRbKLOzyNHezlOdSPM8qlkmA8tIfG9WNqbN88DfzudnfPKc8Vf4ZL44KFH/AcSFW9GUcTvS7dX34vn5cqI35XuffwrJmyqLUf859AduWuPcq+33Mb/SDKoxyxvtjtOPrQwVi8K4kVBvCiIFwXxoiBeFMSL8gbx3DHvCOJFGb9zdyQZKftPhN65a32Xm0D5ftihfso04nfEDvWv/tU/TMIWREN9uQ7it8cWfy7UcwZshBfqzc682YenV78djNyJgnhR1ounjVgC4kVBvCiIFwXxoiBeFMSLUnw0WY3ZleW6z+mdpP8I/8h594+CMfVYvelj9uHNVD7ilxD6aDLPOSHeL4/4JUTF5w1BvLwf/xG/kOnPpIPih9sZrgV/ylwb74R6p79GG/+BeP9zV5ZL5tIqaOczbaivFuWVws14of6uPUD8Aur7+Ps1IH4J60fuYAmIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kX5BoBPqBXW1QvrAAAAAElFTkSuQmCC" alt="" />
这里build.bat和build.xml是放在同一个路径下的。所以可以这样直接调用指令,如果你想放在别的地方是要改路径的。
然后保存,后缀txt改成bat就可以了。
以后,修改完代码之后按下build.bat键盘F3(Eclipse打开文件快捷键)就可以链接合并压缩你的JS和CSS代码了。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAAAcCAIAAAA2tKw9AAACWElEQVRoge2XzYvTQBjG5/8RAkKRUvDsPfdcc/IWWSx7sqygRCGuelm2KK3MQd24B5ODXwum7GYhKdutWrdpcaFUc7ISULZTaDxs89kkTdeUxDAPLyF5M/NM8mPemQSYIZpOp2G3fFJf3a9fv/T8xuUXa4WXN6/slIt8uciXizvlorBx7RCu/x79iOqvcSVAizEHS1IrGRgk7LekRBoAkA7OfALNnzDQhIWBJqyLA1X1/AcGioFmO1IAevvuvaUidUZ5APqxsW8f5x5aYwqAhPHeUOYIUGJkU9VFEtCb8w0gDQrc7oX9MwIUxRYGujRQSZJYlpUkaSVAnVgRUH/jlIFuV6udbq8/GB6faA8ePsJA/wmooiidbm+MEITwbIzUjqYoSmygIglmmr2PzBE2MvvcSbqBOn0BACFA5/xnbu6ky8cySRMoy7L9wRBCaJomhLDdP12/tVHjBeHtnmEY0UCBTQfSwM8uGqhIuhhtUsFAA/x1jaGslu5kpmbo8Yl2NkYQwj9j9ObwqNbUW6PJE2X4vnEQu+Sty5hAfTW+uOQ9l7uVkjUnswcUIbS1XVU7WvvbQP7cvfO42vo1edb+eTRCNV7IHFCZIwAgKpp3eckYUPcu/6FxUG/qrdHkqfr9S+90QclTomvK2OzOv5B8yYiS15iCVfJO9xB/F3onmUGgtgzDEN/t1Xmh+enrwjWUpGhv6XnqkaDoqE0J2n1LTIUOBBrkf762ev3tQbOwKcUR/vWMBRT/yycJNN+BgWKg2Q4M9H8GihUoDDRhJQn0NXc1LBIcJeP6CxOiAsMGHF/kAAAAAElFTkSuQmCC" alt="" />
当然,如果你不想压缩只想合并的话呢,把build.xml压缩那块删了就可以了。
上面这样做其实还是有一些小问题的,后台开发人员如果要去设置路径映射那些的话其实是要去build_output文件夹下面做的,因为这个文件夹才是页面真正的地址(代码已被合并压缩)。
记得跟他们说一下就好了。
作者:manfred Hu
博客:http://www.cnblogs.com/manfredHu
本文地址:http://www.cnblogs.com/manfredHu/p/4719606.html
项目分享:http://yunpan.cn/cdPU8mrHYRLrd 访问密码 d1ba
转载请注明出处谢谢!!!