压缩css与js

使用yuicompressor 进行css和js的压缩

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /bin/sh	
yasuocss="java -jar /root/yuicompressor-2.4.8.jar --type css --charset utf-8"
yasuojs="java -jar /root/yuicompressor-2.4.8.jar --type js --charset utf-8"
######################css
for file in ./SGMag/sites/media/css/sgmag/*.css ./SGMag/sites/media/css/*.css
do
echo "$file"
echo "$file"bk
mv $file "$file"bk
$yasuocss $file"bk" > $file
echo "$file"
done
#######################js
for file in ./SGMag/sites/media/component/*.js ./SGMag/sites/media/*.js ./SGMag/sites/media/pagejs/*.js
do
echo "$file"
echo "$file"bk
mv $file "$file"bk
$yasuojs $file"bk" > $file
echo "$file"
done
########################报错处理
cp -rf ./SGMag/sites/media/pagejs/cluster/hosttools.jsbk ./SGMag/sites/media/pagejs/cluster/hosttools.js