BREAKING CHANGES
- Node.js 22.12 or later is required by every package, and the
purgecsscommand line is built on commander 15, which has the same requirement. - purgecss-webpack-plugin:
webpackis a peer dependency (^5.0.0) instead of a dependency, so it must be installed in your project. Theonlyoption is compared with the chunk names, as documented, instead of with the asset paths: list the chunk names (for an entrypoint, its key inentry) rather than file names or folders. - gulp-purgecss: through2 v5 is an ES module, so the CommonJS build needs a Node.js version that supports
require()of ES modules (included in the requirement above). A file that fails to purge now ends the stream with a plugin error instead of leaving the stream waiting. - rollup-plugin-purgecss:
rollupis a peer dependency, and only thelibfolder is published. - @fullhuman/postcss-purgecss and purgecss-webpack-plugin: a
purgecss.config.jsthat exists but fails to load now fails the build instead of being silently ignored, and in the PostCSS plugin thesafelistof the config file and of the plugin options are combined instead of the plugin option replacing it.
Highlights
- Regular expressions can be written as strings between slashes, such as
"/^btn-/", insafelist,blocklistanddynamicAttributes, so JSON configurations likepostcss.config.jsoncan use patterns.safelist.deepandsafelist.greedyaccept strings as well. dynamicAttributesaccepts regular expressions.- Root-level selectors made only of pseudo-classes, such as
:where(.used):hoveror:host, are kept when what they depend on is used. - The
variablesoption scales linearly with the number of custom properties, keeps variables used across CSS files or only inside@keyframes, and removes the@propertyrules of unused variables. - Keyframes, font faces and variables defined in one CSS file and used in another are kept regardless of the order of the
cssoption. - The CLI reports errors with their message and exits with code 1.
- The JSX and TSX extractors find class names in template literals, conditional expressions, nested JSX and
clsx-style object keys. - Fixes for
rejectedandrejectedCss(ancestors of nested rules, per-file results, trimmed selectors), source maps in gulp-purgecss, config loading on Windows, options forwarding in the rollup and webpack plugins, and the Vue CLI plugin's installed version.
Upgrading
- Use Node.js 22.12 or later.
purgecss-webpack-plugin: runnpm i -D webpackif webpack is not already a direct dependency, and make sureonlylists chunk names.rollup-plugin-purgecss:rollupmust be installed in your project.- Check that
purgecss.config.jsloads without error: a broken config file now fails the build instead of being ignored.
Full details per package: purgecss, @fullhuman/postcss-purgecss, purgecss-webpack-plugin, gulp-purgecss, grunt-purgecss, rollup-plugin-purgecss, @fullhuman/purgecss-from-jsx, @fullhuman/purgecss-from-tsx, purgecss-from-html, purgecss-from-pug, @fullhuman/vue-cli-plugin-purgecss, purgecss-with-wordpress.