hasmin-1.0.3: CSS Minifier

Copyright(c) 2017 Cristian Adrián Ontivero
LicenseBSD3
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Hasmin

Contents

Description

Recommended module to use the library.

Synopsis

Using the library

This section shows a basic library use case.

Given a style sheet, say:

-- Note: We are using the OverloadedStrings extension here

sampleSheet :: Text
sampleSheet = "body { color: #ff0000 } div { margin: 0 0 0 0 }"

Minify it with minifyCSS. In ghci:

> minifyCSS sampleSheet
Right "body{color:red}div{margin:0}"

To modify the minification settings, just use another Config, e.g.:

cfg :: Config
cfg = defaultConfig { colorSettings = ColorMinOff }

Once more in ghci, this time using minifyCSSWith:

> minifyCSSWith cfg sampleSheet
Right "body{color:#ff0000}div{margin:0}"

The output is once more minified, but this time leaving colors as they were originally.

For the complete list of possible options, refer to Config.

minifyCSS :: Text -> Either String Text Source #

Minify Text CSS, using a default set of configurations (with most minification techniques enabled). minifyCSS is equivalent to minifyCSSWith defaultConfig.

minifyCSSWith :: Config -> Text -> Either String Text Source #

Minify Text, based on a Config. To just use a default set of configurations (i.e. defaultConfig), use minifyCSS.