CSS compressor written in OCaml
|
|
11 年 前 | |
|---|---|---|
| dist | 11 年 前 | |
| .gitignore | 11 年 前 | |
| Makefile | 11 年 前 | |
| README.md | 11 年 前 | |
| color_names.ml | 11 年 前 | |
| duplicates.ml | 11 年 前 | |
| lexer.mll | 11 年 前 | |
| main.ml | 11 年 前 | |
| parse.ml | 11 年 前 | |
| parser.mly | 11 年 前 | |
| selector.ml | 11 年 前 | |
| shorthand.ml | 11 年 前 | |
| simple.ml | 11 年 前 | |
| stringify.ml | 11 年 前 | |
| types.ml | 11 年 前 | |
| util.ml | 11 年 前 |
mincss is an extendible CSS minifier written in OCaml. It features a complete parser for the CSS3 language, along with type definitions that are consistent with the official CSS specification and a traversal utility function for use in transformation passes.
For now, there is no easy installation option for mincss (yet). A pre-built 64-bit ELF binary is available for download here. You can also build the binary from source (see Building mincss below).
a, | a,.myclass [class~="foo"]>p{color:#fff}
.myclass [class ~= "foo"] > p { |
color: #fff; |
} |
color: white; | color: #fff;
font-weight: normal; | font-weight: 400;
font-weight: normal; | font: normal 12px/15px sans-serif;
font-size: 12px; |
line-height: 15px; |
font-family: sans-serif; |
Any existing shorthands are first unfolded into their non-shorthand counterparts, after which the last value is used for shorthand generation:
font: normal 12px/15px sans-serif; | font: bold 12px/15px sans-serif;
font-weight: bold; |
The --sort command-line option sorts declarations alphabetically. This option
is disabled by default since it does not affect file size.
Output of mincss -h:
Usage: ./mincss [<options>] [<file> ...]
Generic options:
-h, --help Show this help message
-v, --verbose Verbose mode: show compression rate
-o <file> Output file (defaults to stdout)
<file> ... Input files (default is to read from stdin)
Optimization flags (if none are specified, all are enabled):
-w, --whitespace Eliminate unnecessary whitespaces (has the greatest effect, omit for pretty-printing)
-c, --simple Shorten colors and font weights
-s, --shorthands Generate shorthand properties
-d, --duplicates Prune duplicate properties (WARNING: may affect cross-browser hacks)
-p, --pretty Shorthand for -c -s -d
-e, --echo Just parse and pretty-print, no optimizations
Formatting options:
--sort Sort declarations in each selector group
Dependencies are OCaml 4.0 and menhir.
Bootstrapping on a Debian system can be done as follows:
$ sudo apt-get install ocaml opam git
$ opam init
$ opam switch 4.01.0
$ opam install menhir
$ git clone git@github.com:taddeus/mincss.git
$ cd mincss
$ make
$ ./mincss --help