i10416 / cssminifier   0.0.3

GitHub

This library is a simple, dependency free css minifier supporting Scala 2.13, 3 on JVM, JS and Native Platform.

Scala versions: 3.x 2.13 2.12
Scala.js versions: 1.x
Scala Native versions: 0.4

Simple CSS Minifier in Pure Scala

Release

scala 2.13 scala 3
Sonatype Nexus (Snapshots)
Maven Central
Sonatype Nexus (Snapshots)
Maven Central

This library is a simple, dependency free css minifier supporting Scala 2.13, 3 on JVM, JS and Native Platform.

Algorithm is written in reference to YUI or.

Following features are supported.

  • remove leading whitespace-like chars
  • remove trailing whitespace-like chars
  • remove last semi-colon in braces
  • remove repeated semi-colons
  • remove comments except ones start with !
  • remove empty rules
  • compress zeros(e.g. margin:0 0 0 0; => margin:0,border:none;=>border:0)
  • collect @charset and keep only the first one

Install

libraryDependencies += "dev.i10416" %% "cssminifier" % "0.0.2"

For JS or Native platform, use %%% instead of %%.

libraryDependencies += "dev.i10416" %%% "cssminifier" % "0.0.2"

Run

import dev.i10416.CSSMinifier

CSSMinifier.run("<css string>")

How to contribute?

  • Give it a star⭐
  • Drop the feedback to the author @i10416
  • Send a PR with fixes of typos/bugs/etc🐛

License

Licensed under the Apache License, Version 2.0.