Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cssnano

Package Overview
Dependencies
Maintainers
8
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssnano

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

  • 6.0.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created

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

Keywords

FAQs

Package last updated on 24 Feb 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc