Gathering detailed insights and metrics for @dialonce/purgecss-webpack-plugin
Gathering detailed insights and metrics for @dialonce/purgecss-webpack-plugin
Gathering detailed insights and metrics for @dialonce/purgecss-webpack-plugin
Gathering detailed insights and metrics for @dialonce/purgecss-webpack-plugin
npm install @dialonce/purgecss-webpack-plugin
Typescript
Module System
Node Version
NPM Version
JavaScript (96.8%)
CSS (2.39%)
HTML (0.81%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
137 Commits
5 Watchers
16 Branches
Updated on Sep 28, 2018
Latest Version
1.3.2
Package Id
@dialonce/purgecss-webpack-plugin@1.3.2
Unpacked Size
25.37 kB
Size
6.07 kB
File Count
6
NPM Version
6.4.1
Node Version
8.11.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
2
20
The only change we made was that we removed ignore of the stylesheets (css, sass files and similar) by this plugin.
Webpack plugin to remove unused css.
1npm i purgecss-webpack-plugin -D
1const path = require('path') 2const glob = require('glob') 3const MiniCssExtractPlugin = require('mini-css-extract-plugin') 4const PurgecssPlugin = require('purgecss-webpack-plugin') 5 6const PATHS = { 7 src: path.join(__dirname, 'src') 8} 9 10module.exports = { 11 entry: './src/index.js', 12 output: { 13 filename: 'bundle.js', 14 path: path.join(__dirname, 'dist') 15 }, 16 optimization: { 17 splitChunks: { 18 cacheGroups: { 19 styles: { 20 name: 'styles', 21 test: /\.css$/, 22 chunks: 'all', 23 enforce: true 24 } 25 } 26 } 27 }, 28 module: { 29 rules: [ 30 { 31 test: /\.css$/, 32 use: [ 33 MiniCssExtractPlugin.loader, 34 "css-loader" 35 ] 36 } 37 ] 38 }, 39 plugins: [ 40 new MiniCssExtractPlugin({ 41 filename: "[name].css", 42 }), 43 new PurgecssPlugin({ 44 paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }), 45 }), 46 ] 47}
If you need multiple paths use the npm package glob-all
instead of glob
, then you can use this syntax:
1new PurgecssPlugin({ 2 paths: glob.sync([ 3 // ... 4 ]) 5}),
to filter out directories see the glob-all documentation here.
1const path = require('path') 2const glob = require('glob') 3const ExtractTextPlugin = require('extract-text-webpack-plugin') 4const PurgecssPlugin = require('purgecss-webpack-plugin') 5 6const PATHS = { 7 src: path.join(__dirname, 'src') 8} 9 10module.exports = { 11 entry: './src/index.js', 12 output: { 13 filename: 'bundle.js', 14 path: path.join(__dirname, 'dist') 15 }, 16 module: { 17 rules: [ 18 { 19 test: /\.css$/, 20 use: ExtractTextPlugin.extract({ 21 fallback: 'style-loader', 22 use: 'css-loader?sourceMap' 23 }) 24 } 25 ] 26 }, 27 plugins: [ 28 new ExtractTextPlugin('[name].css?[hash]'), 29 new PurgecssPlugin({ 30 paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }) 31 }) 32 ] 33}
The options available in purgecss Configuration are also available in the webpack plugin with the exception of css and content.
With the webpack plugin, you can specified the content that should be analyzed by purgecss with an array of filename. It can be html, pug, blade, ... files. You can use a module like glob
or glob-all
to easily get a list of files.
1const PurgecssPlugin = require('purgecss-webpack-plugin') 2const glob = require('glob') 3const PATHS = { 4 src: path.join(__dirname, 'src') 5} 6 7// In the webpack configuration 8new PurgecssPlugin({ 9 paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }) 10})
If you want to regenerate the paths list on every compilation (e.g. with --watch
), then you can also pass a function:
1new PurgecssPlugin({ 2 paths: () => glob.sync(`${PATHS.src}/**/*`, { nodir: true }) 3})
You can specify entrypoints to the purgecss-webpack-plugin with the option only:
1new PurgecssPlugin({ 2 paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }), 3 only: ['bundle', 'vendor'] 4})
Similar as for the paths
option, you also can define functions for the these options:
1function collectWhitelist() { 2 // do something to collect the whitelist 3 return ['whitelisted']; 4} 5function collectWhitelistPatterns() { 6 // do something to collect the whitelist 7 return [/^whitelisted-/]; 8} 9 10// In the webpack configuration 11new PurgecssPlugin({ 12 whitelist: collectWhitelist, 13 whitelistPatterns: collectWhitelistPatterns 14})
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning.
Purgecss was originally thought as the v2 of purifycss. And because of it, it is greatly inspired by it. The plugins such as purgecss-webpack-plugin are based on the purifycss plugin. Below is the list of the purifycss repositories:
This project is licensed under the MIT License - see the LICENSE file for details
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
security policy file not detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More