0.2.1 • Published 2 years ago

css-mini-mini-mini v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

CSS-mini-mini-mini

CSS (almost) remynifier

npmjs.org version

About

(Let me introduce some theory first). In the past, there was this great article https://luisant.ca/remynifier by Remy Luisan which introduced the idea of running multiple CSS minifiers on the same [style] file [in serial] to get better minification results than any single CSS minifier achieves on it's own. Somewhat crazy idea, but I liked the results.

This project takes the article's general idea and implements it for NodeJS. All CSS minifiers (cleancss, cssnano, csso and crass) are included as npm dependencies, so can you are good to go right of the bat.

Currently there a few bells and whistles missing. For example, current algorithm is basically greedy and only considers the best branch. This means it does not always find the optimal solution... although it might be close enough ¯\(ツ)/¯.

Features

  • 💻 Usable as a CLI
  • 📦 Installable as npm package
  • 📂 Reading files or stdin
  • 🗳 Writing files or stdout
  • 🎁 Self contained with all minifiers as direct dependencies

Benchmark

I haven't done any exhaustive benchmarks yet. The only comparison I have is from the CSS on my personal site at https://github.com/matejkosiarcik/matejkosiarcik.com.

-CSS size [B]possible gain [%]
Original1841563.29
crass1092638.14
cleancss1027534.22
csso956929.37
cssnano779512.29
css-mini-mini-mini6759-

As we can see, css-mini-mini-mini can gain between 12% and 38% over a single minifier.

Installation

npm install --save-dev css-mini-mini-mini

Usage

# optimize single file
$ cmmm style.css

# optimize multiple files
$ cmmm style.css vendor.css

# optimize all css files in directory
$ cmmm dist/

When in doubt, get help:

$ cmmm --help
cmmm [file] [options...]

General description...

Positionals:
  file  Input file path (- for stdin)                    [string] [default: "-"]

Options:
  -h, --help     Show usage                                            [boolean]
  -V, --version  Show current version                                  [boolean]
  -o, --output   Output file path (- for stdout)         [string] [default: "-"]
  -v, --verbose  Verbose logging                                       [boolean]

License

The project is licensed under MIT License. See LICENSE for full details.