Socket
Socket
Sign inDemoInstall

cssnano

Package Overview
Dependencies
69
Maintainers
8
Versions
140
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssnano

A modular minifier, built on top of the PostCSS ecosystem.


Version published
Maintainers
8
Weekly downloads
10,597,615
decreased by-6.49%

Weekly downloads

Package description

What is cssnano?

cssnano is a modular minifier for CSS, which uses PostCSS for its plugin architecture. It is aimed at reducing the size of CSS files by applying various optimizations, such as removing whitespace, comments, and unnecessary prefixes, as well as merging rules and minifying values.

What are cssnano's main functionalities?

Preset Configuration

This code demonstrates how to use cssnano with its default preset to minify a CSS string. The 'process' method is called on the PostCSS instance with cssnano as a plugin.

const cssnano = require('cssnano');
const postcss = require('postcss');

postcss([cssnano()])
.process(css, { from: undefined })
.then(result => {
  console.log(result.css);
});

Custom Plugin Usage

This code shows how to use cssnano with other PostCSS plugins like autoprefixer. It demonstrates the use of a custom preset configuration for cssnano.

const cssnano = require('cssnano');
const autoprefixer = require('autoprefixer');
const postcss = require('postcss');

postcss([autoprefixer, cssnano({ preset: 'default' })])
.process(css, { from: undefined })
.then(result => {
  console.log(result.css);
});

Optimizing for Production

This code snippet illustrates how to use cssnano for production by disabling source maps and using the default preset for optimization.

const cssnano = require('cssnano');
const postcss = require('postcss');

postcss([cssnano({ preset: 'default' })])
.process(css, { from: undefined, map: false })
.then(result => {
  console.log(result.css);
});

Other packages similar to cssnano

Readme

Source

cssnano

For documentation, please see the following links:

  • Repository: https://github.com/cssnano/cssnano
  • Website: http://cssnano.co

Keywords

FAQs

Last updated on 28 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your 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