パッケージの詳細

purgecss

FullHuman3.5mMIT7.0.2

Remove unused css selectors

optimize, optimization, remove, unused

readme

PurgeCSS

npm npm GitHub Dependabot

PurgeCSS logo

What is PurgeCSS?

When you are building a website, chances are that you are using a css framework like Bootstrap, Materializecss, Foundation, etc... But you will only use a small set of the framework and a lot of unused css styles will be included.

This is where PurgeCSS comes into play. PurgeCSS analyzes your content and your css files. Then it matches the selectors used in your css files with the ones in your content files. It removes unused selectors from your css, resulting in smaller css files.

Sponsors 🥰

Documentation

You can find the PurgeCSS documentation on this website.

Table of Contents

PurgeCSS

Plugins

Guides

Getting Started

Installation

npm install purgecss --save-dev

Usage

import { PurgeCSS } from "purgecss";
const purgeCSSResults = await new PurgeCSS().purge({
  content: ["**/*.html"],
  css: ["**/*.css"],
});

Packages

This repository is a monorepo that we manage using Lerna. That means that we actually publish several packages to npm from the same codebase, including:

Package Version Description
purgecss npm The core of PurgeCSS
postcss-purgecss npm (scoped) PostCSS plugin for PurgeCSS
purgecss-webpack-plugin npm Webpack plugin for PurgeCSS
gulp-purgecss npm Gulp plugin for PurgeCSS
grunt-purgecss npm Grunt plugin for PurgeCSS
rollup-plugin-purgecss npm Rollup plugin for PurgeCSS
purgecss-from-html npm Html extractor for PurgeCSS
purgecss-from-pug npm Pug extractor for PurgeCSS
purgecss-with-wordpress npm Collection of safelist items for WordPress
vue-cli-plugin-purgecss npm Vue CLI Plugin for PurgeCSS

更新履歴

(2024-03-29)

6.0.0 (2024-03-29)

Bug Fixes

  • collect of used variables for changed selector (#1217) (9fbb592)
  • gulp-purgecss: move vinyl-sourcemaps-apply to deps #999 (7858b7a)

Features

(2022-09-13)

5.0.0 (2022-09-13)

Bug Fixes

  • add safelist variables to postcss-purgecss #840 (c822058)
  • gulp-purgecss: support skippedContentGlobs option #853 (b72de77)
  • Purgecss webpack plugin/only filter fix (#933) (f8e4c2c)
  • purgecss-webpack-plugin: add sourcemap support #409 (b3f73ed)
  • purgecss-webpack-plugin: export as named export as well as default (#821) (a6a2c8e)
  • wrong path import (4f3ddd0)

Features

  • add source map support #526 (f2a9c5a)
  • gulp-purgecss: add support for gulp-sourcemaps #257 (55c26d2)
  • postcss-purgecss: load options from purgecss config (4de3bd8)
  • purgecss-webpack-plugin: load config file automatically #767 (726faaa)

BREAKING CHANGES

  • purgecss-webpack-plugin: drop webpack 4 support

(2022-09-13)

4.1.0 (2021-11-28)

Bug Fixes

  • Allow Absolute Paths (#679) (15335a2)
  • css variable removed when declared in wrong order (89ece42), closes #518
  • Fix interaction with other plugins (#647) (fb08e3a)
  • grunt-purgecss: Fix plugin not ouputting all files (#723) (646e419)
  • gulp-purgecss: fix support for stream input (fd5d3bf)
  • Keep keyframe decimals for prefixed @keyframes (#749) (b804441)
  • purgecss-from-pug: class attribute with multiple values not correctly handled with pug (#678) (ba6285d), closes #677

Features

(2021-06-07)

Bug Fixes

  • Allow Absolute Paths (#679) (15335a2)
  • purgecss-from-pug: class attribute with multiple values not correctly handled with pug (#678) (ba6285d), closes #677
  • css variable removed when declared in wrong order (89ece42), closes #518
  • Fix interaction with other plugins (#647) (fb08e3a)

Features

  • add dynamicAttributes option (2f9cc65)

4.0.3 (2021-03-20)

Features

  • add dynamic attributes option (9b0fdc3), closes #588
  • add skippedContentGlobs option to webpack and gulp plugin (e3dce1a)

4.0.2 (2021-02-21)

4.0.1 (2021-02-21)

Bug Fixes

  • attribute selector with spaces being removed (418dc7e), closes #392
  • webpack plugin option blocklist types (5b029c2)

Features

  • add option blocklist to webpack plugin (#610) (0148cea)

4.0.0 (2021-01-17)

Bug Fixes

  • test: webpack test type error (c41ad27)

Features

  • postcss-purgecss: remove compatibility with postcss 7 (48ce28f), closes #488 #540

BREAKING CHANGES

  • postcss-purgecss: dropping support for postcss 7 Drop PostCSS 7 support, use @fullhuman/postcss-purgecss 3.0 with PostCSS 7.

(2020-12-15)

  • postcss-purgecss remove postcss 8 as peer dependency
  • purgecss-webpack-plugin fix backward compatibility with webpack 4

3.1 (2020-12-14)

  • PurgeCSS Update to PostCSS 8
  • postcss-purgecss Add compatibility with PostCSS 8
  • purgecss-webpack-plugin Fix deprecation warning with Webpack 5

Bug Fixes

3.0 (2020-09-06)

Features

  • CLI: add blocklist option (3961afb)
  • add blocklist option (04223f7)
  • add safelist option, replace whitelist
  • add safelist keyframes and css variables (dc59d30), closes #418 #439

(2019-11-23)

2.0.1-alpha.0 (2019-10-08)

Features

  • postcss-purgecss: add package (2b0616f)

1.4.0 (2019-09-01)

1.3.0 (2019-04-20)

1.2.0 (2019-04-05)

Bug Fixes

  • package: update postcss to version 7.0.0 (3657c4d)
  • package: update postcss-selector-parser to version 6.0.0 (8dd2442)

1.0.0 (2018-05-22)

Reverts

  • Revert "adds keepChildren ability from whitelistPatterns Object[]" (c52c81b)
  • Revert "fixes style code" (2213be6)

0.20.1 (2018-03-12)

0.20.0 (2018-01-30)

0.18.0 (2018-01-04)

0.16.0 (2017-12-18)

0.14.0 (2017-12-07)

0.9.0 (2017-11-07)

0.8.0 (2017-10-23)

0.4.0 (2017-07-31)

0.3.0 (2017-07-23)

0.2.0 (2017-07-16)