Socket
Socket
Sign inDemoInstall

postcss-colormin

Package Overview
Dependencies
15
Maintainers
8
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

postcss-colormin

Minify colors in your CSS files with PostCSS.

    6.0.0
    GitHub
    npm

Version published
Maintainers
8
Weekly downloads
11,092,976
increased by3.44%

Weekly downloads

Package description

What is postcss-colormin?

The postcss-colormin package is a PostCSS plugin designed to optimize color values within your CSS. It reduces the size of color values and converts them into more efficient formats when possible, contributing to smaller CSS file sizes and potentially faster load times for web pages.

What are postcss-colormin's main functionalities?

Minifying color values

This feature takes a CSS string with color values and uses the colormin plugin to minimize the color values. For example, it can convert '#ff0000' to 'red', which is shorter.

"const postcss = require('postcss');
const colormin = require('postcss-colormin');

postcss([colormin()]).process('a { color: #ff0000; }').then(result => {
  console.log(result.css); // Output: 'a { color: red; }'
});"

Converting RGBA to hex when possible

This feature optimizes RGBA color values to their hex or named color equivalent when the alpha value is 1, thus reducing the size of the CSS.

"const postcss = require('postcss');
const colormin = require('postcss-colormin');

postcss([colormin()]).process('a { background-color: rgba(255, 0, 0, 1); }').then(result => {
  console.log(result.css); // Output: 'a { background-color: red; }'
});"

Other packages similar to postcss-colormin

Readme

Source

postcss-colormin

Minify colors in your CSS files with PostCSS.

Install

With npm do:

npm install postcss-colormin --save

Example

var postcss = require('postcss')
var colormin = require('postcss-colormin');

var css = 'h1 {color: rgba(255, 0, 0, 1)}';
console.log(postcss(colormin()).process(css).css);

// => 'h1 {color:red}'

For more examples see the tests.

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

Keywords

FAQs

Last updated on 27 Mar 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc