Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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.
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);
});
clean-css is a fast and efficient CSS optimizer for Node.js and the browser. It performs similar tasks to cssnano, such as minifying CSS, but it does not use PostCSS as its foundation. It provides its own API and set of features for optimizing CSS files.
purgecss is a tool to remove unused CSS, which can be used in conjunction with CSS minifiers like cssnano. While cssnano focuses on optimizing the CSS that is already being used, purgecss helps to reduce file size by stripping out styles that are not used in your HTML or JavaScript files.
uglifycss is a simple, straightforward CSS minifier. It lacks the modularity and plugin system of cssnano but is easy to use for basic CSS minification tasks. It is suitable for projects that require a simpler setup without the need for extensive configuration or additional plugins.
A modular minifier, built on top of the PostCSS ecosystem.
![Gitter](https://badges.gitter.im/Join Chat.svg)
cssnano is a modular minifier that aims to utilise small modules from the
PostCSS ecosystem, rather than being an all-encompassing module that may be
difficult to contribute to. Because it is written on top of PostCSS, it is able
to do more than simple whitespace transforms - including advanced optimisations
such as custom identifier reduction, z-index
rebasing, and adjacent selector
merging.
For further details check out the website:
Pull requests are welcome. If you add functionality, then please add unit tests to cover it.
MIT © Ben Briggs
FAQs
A modular minifier, built on top of the PostCSS ecosystem.
The npm package cssnano receives a total of 2,076,840 weekly downloads. As such, cssnano popularity was classified as popular.
We found that cssnano demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.