Node.JS的CSS壓縮器 clean-css

jopen 12年前發布 | 52K 次閱讀 CSS 前端技術 Node.js

clean-css 是一個非常簡單的 CSS 壓縮程序,可以刪除 CSS 中一些無用的空格、評論以及每個選擇器后面的分號等。

在命令行中的使用方法:

cleancss -o style.min.css style.css
cat theme.css feature1.css feature2.css feature3.css | cleancss -o features.css
cat theme.css feature1.css | cleancss | gzip -9 -c > feature1.css.gz

也可在 Node.js 中使用:

# Get the clean-css package
var cleanCSS = require('clean-css');

# Read in the source of a file or use hard-coded CSS...
var source = "body { color: red; font-weight: bold; }";

# Minify!
var minifiedCSS = cleanCSS.process(source);

項目主頁:http://www.baiduhome.net/lib/view/home/1340670612014

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!