1.1.3 • Published 7 days ago

@csstools/postcss-minify v1.1.3

Weekly downloads
-
License
MIT-0
Repository
github
Last release
7 days ago

PostCSS Minify

npm install @csstools/postcss-minify --save-dev

PostCSS Minify is a very basic CSS minifier.

It guarantees two things :

  • browsers can not tell the difference between the original and the minified CSS
  • lawyers can not tell the difference between the original and the minified CSS

Compared to other minifiers, PostCSS Minify is purely focused on correctness and fidelity.
PostCSS Minify only collapses whitespace and comments while preserving those comments that are important for legal compliance.

PostCSS Minify is not a CSS optimizer, it does not try to reduce the size of the CSS file by altering the CSS itself.

/*
 * License : MIT-0
 * legal text is preserved
 */

/*
 * Copyright: CSSTools Authors
 * legal text is preserved
 */

/*! an important comment */

:root {
	--mainColor: #12345678;
}

body {
	color: var(--mainColor);
	font-family: system-ui;
}

a {
	color: rgb(0 0 100% / 90%);

	&:hover {
		color: rebeccapurple;
	}

	> span {
		color: color-mix(in oklch, cyan, green 25%);
	}
}

:is(input, button):is(:hover, :focus) {
	color: oklch(40% 0.268735435 34.568626);
}

becomes :

/*
 * License : MIT-0
 * legal text is preserved
 *//*
 * Copyright: CSSTools Authors
 * legal text is preserved
 *//*! an important comment */:root{--mainColor: #12345678;}body{color:var(--mainColor);font-family:system-ui}a{color:rgb(0 0 100% / 90%);&:hover{color:rebeccapurple}> span{color:color-mix(in oklch, cyan, green 25%)}}:is(input, button):is(:hover, :focus){color:oklch(40% 0.268735435 34.568626)}

Usage

Add PostCSS Minify to your project:

npm install postcss @csstools/postcss-minify --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssMinify = require('@csstools/postcss-minify');

postcss([
	postcssMinify(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Minify runs in all Node environments, with special instructions for:

1.1.3

7 days ago

1.1.2

7 days ago

1.1.1

2 months ago

1.1.0

4 months ago

1.0.3

5 months ago

1.0.2

7 months ago

1.0.1

8 months ago

1.0.0

9 months ago