# uglifycss

> Port of YUI CSS Compressor to NodeJS

Latest version **0.0.29** (published 2018-03-21) · MIT license · 71.6K weekly downloads

## Install

```sh
npm install uglifycss
pnpm add uglifycss
yarn add uglifycss
bun add uglifycss
```

Provides the command `uglifycss`.

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.29 |
| Published | 2018-03-21 |
| First published | 2011-05-29 |
| Weekly downloads | 71.6K |
| License | MIT |
| TypeScript types | separate (@types/uglifycss) |
| Module format | CommonJS |
| Node | >=6.4.0 |
| Dependencies | 0 |
| Unpacked size | 37.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 282 |
| Author | Franck Marcia |
| Maintainers | fmarcia |
| Keywords | css, stylesheet, uglify, minify |

## Links

- npm: https://www.npmjs.com/package/uglifycss
- Repository: https://github.com/fmarcia/uglifycss
- Issues: https://github.com/fmarcia/uglifycss/issues
- npm.io page: https://npm.io/package/uglifycss

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads
- [@fontsource/amiri](https://npm.io/package/@fontsource/amiri.md) — 6.8K weekly downloads

## Recent versions

- 0.0.29 (latest) — 2018-03-21
- 0.0.28 — 2018-02-25
- 0.0.27 — 2017-05-01
- 0.0.26 — 2017-04-23
- 0.0.25 — 2016-10-19
- 0.0.24 — 2016-10-17
- 0.0.23 — 2016-10-16
- 0.0.22 — 2016-10-14
- 0.0.21 — 2016-08-15
- 0.0.20 — 2015-12-29
- 0.0.19 — 2015-11-28
- 0.0.18 — 2015-08-28
- 0.0.17 — 2015-08-04
- 0.0.16 — 2015-08-01
- 0.0.15 — 2015-05-01
- … 11 more at https://npm.io/package/uglifycss/versions

## README

UglifyCSS is a port of [YUI Compressor](https://github.com/yui/yuicompressor) to [NodeJS](http://nodejs.org) for its CSS part. Its name is a reference to the awesome [UglifyJS](https://github.com/mishoo/UglifyJS) but UglifyCSS is not a CSS parser. Like YUI CSS Compressor, it applies many regexp replacements. Note that a [port to JavaScript](https://github.com/yui/ycssmin) is also available in the YUI Compressor repository.

UglifyCSS passes successfully the test suite of YUI compressor CSS.

Be sure to submit valid CSS to UglifyCSS or you could get weird results.

### Installation

For a command line usage:
```sh
$ npm install uglifycss -g
```

For API usage:
```sh
$ npm install uglifycss
```

From Github:
```sh
$ git clone git://github.com/fmarcia/UglifyCSS.git
```

### Command line

```sh
$ uglifycss [options] [filename] [...] > output
```

Options:

* `--max-line-len n` adds a newline (approx.) every `n` characters; `0` means no newline and is the default value
* `--expand-vars` expands variables; by default, `@variables` blocks are preserved and `var(x)`s are not expanded
* `--ugly-comments` removes newlines within preserved comments; by default, newlines are preserved
* `--cute-comments` preserves newlines within and around preserved comments
* `--convert-urls d` converts relative urls using the `d` directory as location target
* `--debug` prints full error stack on error
* `--output f` puts the result in `f` file

If no file name is specified, input is read from stdin.

### API

2 functions are provided:

* `processString( content, options )` to process a given string
* `processFiles( [ filename1, ... ], options )` to process the concatenation of given files

Options are identical to the command line:
* `<int> maxLineLen` for `--max-line-len n`
* `<bool> expandVars` for `--expand-vars`
* `<bool> uglyComments` for `--ugly-comments`
* `<bool> cuteComments` for `--cute-comments`
* `<string> convertUrls` for `--convert-urls d`
* `<bool> debug` for `--debug`

Both functions return uglified css.

#### Example

```js
var uglifycss = require('uglifycss');

var uglified = uglifycss.processFiles(
    [ 'file1', 'file2' ],
    { maxLineLen: 500, expandVars: true }
);

console.log(uglified);
```

### License

UglifyCSS is MIT licensed.

---
_Source: https://npm.io/package/uglifycss · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
