博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
node压缩css_Node.js CSS压缩器:clean-css
阅读量:2519 次
发布时间:2019-05-11

本文共 2327 字,大约阅读时间需要 7 分钟。

node压缩css

One of my recent finds on the goldmine that is GitHub is . The GoalSmashers team has created three notable (or at least useful to me) utilities you all should know about:

我最近在金矿上找到的GitHub之一是 。 GoalSmashers团队创建了三个大家都应该了解的著名(或至少对我有用)的实用程序:

  • : embeds imagery into stylesheets via Base64 encoding

    :通过Base64编码将图像嵌入样式表

  • : minifies and concatenates CSS files

    :缩小并连接CSS文件

  • : builds, minifies, and bundles JavaScript and CSS files in the same command

    :在同一命令中生成,缩小和捆绑JavaScript和CSS文件

In this post, I'd like to take a few moments to look at clean-css, a CSS dead simple minification package. The clean-css utility does just what you would expect from a CSS minifier: strips unnecessary whitespace, removes comments, deletes the last semicolon of every selector, and more!

在本文中,我想花点时间看一下clean-css,这是一个CSS无效的简单压缩包。 clean-css实用程序可以实现CSS缩小器的预期功能:去除不必要的空格,删除注释,删除每个选择器的最后一个分号等等!

安装clean-css (Installing clean-css)

clean-css can be installed via NPM, which is super convenient:

clean-css可以通过NPM安装,这非常方便:

npm install clean-css

You can also simply .

您也可以直接 。

使用Shell的clean-css (Using clean-css from Shell)

Using clean-css from the shell is simple:

从shell使用clean-css很简单:

cleancss -o style.min.css style.css

You can even use basic shell commands to pass concatenated input in:

您甚至可以使用基本的shell命令在以下位置传递串联的输入:

cat theme.css feature1.css feature2.css feature3.css | cleancss -o features.css

Or chain gzipping as well:

或链式压缩:

cat theme.css feature1.css | cleancss | gzip -9 -c > feature1.css.gz

Compressing via shell commands is super useful for quick manual minfication or intense build processes.

通过shell命令进行压缩对于快速手动压缩或密集的构建过程非常有用。

通过NodeJS Apps使用clean-css (Using clean-css via NodeJS Apps)

clean-css can also be used from within your JavaScript code:

clean-css也可以在您JavaScript代码中使用:

# Get the clean-css packagevar 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);

A huge kudos goes to the GoalSmashers team for their useful utilities, and for open-sourcing them for all of us to use! I have a feeling some of you will be tweaking (or creating) your build process based on their work. Happy optimizing!

对于GoalSmashers团队有用的实用程序,以及将它们开源供我们所有人使用,我们深表感谢! 我感觉有些人会根据他们的工作来调整(或创建)构建过程。 优化愉快!

翻译自:

node压缩css

转载地址:http://kuvwd.baihongyu.com/

你可能感兴趣的文章
淘宝爆款详情页制作的几个方法(理论)
查看>>
c语言单链表实现
查看>>
php无限极分类
查看>>
08——别让常逃离析构函数
查看>>
echarts.js中的图表大小自适应
查看>>
Linux总结
查看>>
llg的农场(farm)
查看>>
Delphi的FIFO实现
查看>>
mybatis入门相关笔记
查看>>
油猴 greasemonkey 背景音乐 火狐 chrome 背景音乐
查看>>
springMVC运行流程
查看>>
JavaScript 类
查看>>
COM笔记-动态链接
查看>>
如何使用vs2012单步调试uGUI(unity3d 5.3f4)
查看>>
跟我一起读postgresql源码(十一)——Executor(查询执行模块之——Materialization节点(上))...
查看>>
CSS画水平分割线
查看>>
node.js安装后出现环境变量错误找不到node
查看>>
alg: 首尾相连的珠子
查看>>
lua 5.3最简单plugin编写
查看>>
jquery中用each遍历jquery对象,普通object对象,数组
查看>>