7 releases

0.3.1 Nov 22, 2022
0.3.0 Nov 22, 2022
0.2.2 Jan 31, 2021
0.1.1 Jan 23, 2021

#554 in Parser implementations

Download history 3169/week @ 2024-01-14 2983/week @ 2024-01-21 3556/week @ 2024-01-28 3495/week @ 2024-02-04 2998/week @ 2024-02-11 2872/week @ 2024-02-18 2726/week @ 2024-02-25 2306/week @ 2024-03-03 664/week @ 2024-03-10 597/week @ 2024-03-17 612/week @ 2024-03-24 630/week @ 2024-03-31 492/week @ 2024-04-07 592/week @ 2024-04-14 681/week @ 2024-04-21 526/week @ 2024-04-28

2,364 downloads per month
Used in 24 crates (6 directly)

Apache-2.0/MIT

110KB
3K SLoC

CSS minify

CSS minification library based on nom. This library parses css input, minifies it and applies some level-dependent optimizations to it.

use css_minify::optimizations::{Minifier, Level};
fn main() {
    assert_eq!(
        Minifier::default().minify(
            r#"
                 #some_id, input {
                     padding: 5px 3px; /* Mega comment */
                     color: white;
                 }
                 
                 
                 /* this is are test id */
                 #some_id_2, .class {
                     padding: 5px 4px; /* Mega comment */
                     Color: rgb(255, 255, 255);
                 }
             "#,
            Level::Three
        ),
        Ok("#some_id,input{padding:5px 3px;color:white}#some_id_2,.class{padding:5px 4px;color:#fff}".into())
    )
}

CSS minifier

Web version also available https://css-minify.panfilov.tech/

CLI wrapper for css-minify library.

css-minifier 0.1

USAGE:
    css-minifier [OPTIONS] --input <input>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -i, --input <input>      css which will be minified
    -l, --level <level>      Optimization levels:
                                 0 - Without optimizations 
                                 1 - Remove whitespaces, replace `0.` to `.` and others non
                             dangerous optimizations
                                 2 - Level One + shortcuts (margins, paddings, backgrounds and etc).
                             In mostly cases it's non dangerous optimizations, but be careful
                                 3 - Level Two + merge @media and css blocks with equal
                             screen/selectors. It is a danger optimizations, because ordering of
                             your css code may be changed.
                              [default: 1]
    -o, --output <output>    output to optimized variant

Example

css-minifier -i "~/test.css" -o "~/test.min.css" -l 3

Dependencies

~3.5MB
~70K SLoC