概要 †
CSSのminifyをコマンドで行います。
手順 †
- uglifycssをインストール
1
|
| npm install -g uglifycss
|
サンプル †
サンプルスクリプト全体はスクリプト/deploy.shを参照
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| -
|
|
!
-
|
|
|
|
|
!
| function CSSOptimize() {
find "$workPath/code/skin" -type f ! -name '*.min.css' -and -name '*.css' -print0 |
while read -r -d '' orgFilePath
do
local cnvFilePath=${orgFilePath%%.css}_$DATETIME.min.css
uglifycss "$orgFilePath" > "$cnvFilePath" &&
find "$workPath/code" -type f -print0 |
xargs -0 sed -i "s/`basename $orgFilePath .css`\.css/`basename $cnvFilePath .min.css`\.min\.css/g" &&
$RM "$orgFilePath" || { echo "[!!ERROR!!] failed to CSS optimize"; exit 1; }
done
}
|
検証時の環境 †