css js 圖片壓縮批處理命令(基於YUI Compressor)

來源:互聯網
上載者:User

複製代碼 代碼如下:@echo off
::設定YUI Compressor啟動目錄
SET YUIFOLDER=D:\yuicompressor-2.4.2\build\

::設定你的JS和CSS根目錄,指令碼會自動按樹層次尋找和壓縮所有的JS和CSS
SET INFOLDER=D:\jscss\src
SET OUTFOLDER=D:\jscss\build
echo 正在尋找 JavaScript, CSS ...
chdir /d %INFOLDER%

for /r . %%a in (*.js *.css) do (
copy %%a "%OUTFOLDER%\" && echo 複製%%~fa成功 || echo 複製%%~fa失敗,請檢查檔案是否存在!
@echo 正在壓縮 %%~a ...
@java -jar %YUIFOLDER%\yuicompressor-2.4.2.jar --charset UTF-8 %%~fa -o %%~fa
)
@echo CSS JS壓縮完成!

for /r . %%b in (*.gif) do (
@echo 正在尋找 gif...
@pngout %%~fb /kp
del /q/f %%~fb
)

@echo gif轉換完成!

for /r . %%c in (*.png) do (
@echo 正在尋找 png...
@pngout %%~fc
)

@echo png壓縮完成!

pause & exit

相關文章

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.