
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
purifycss-webpack
Advanced tools
This plugin uses PurifyCSS to remove unused selectors from your CSS. You should use it with the extract-text-webpack-plugin.
Without any CSS file being emitted as an asset, this plugin will do nothing. You can also use the file
plugin to drop a CSS file into your output folder, but it is highly recommended to use the PurifyCSS plugin with the Extract Text plugin.
This plugin replaces earlier purifycss-webpack-plugin and it has a different API!
First, install it:
npm install purifycss-webpack --save-dev
Then configure as follows:
const path = require('path');
const glob = require('glob');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyPlugin = require('purifycss-webpack');
module.exports = {
entry: {...},
output: {...},
module: {
rules: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader'
})
}
]
},
plugins: [
new ExtractTextPlugin('[name].[contenthash].css'),
// Make sure this is after ExtractTextPlugin!
new PurifyPlugin({
// Give paths to parse for rules. These should be absolute!
paths: glob.sync(path.join(__dirname, 'app/*.html')),
})
]
};
And, that's it! Your scripts and view files will be scanned for classes, and those that are unused will be stripped off your CSS - aka. "purified".
You can pass an object (
<entry> -> [<absolute path>]
) topaths
if you want to control the behavior per entry.
This plugin, unlike the original PurifyCSS plugin, provides special features, such as scanning the dependency files. You can configure using the following fields:
Property | Description |
---|---|
fileExtensions | An array of file extensions for determining used classes. Defaults to ['.css'] . |
moduleExtensions | An array of file extensions for determining used classes within node_modules . Defaults to [] , but ['.html'] can be useful here. |
paths | An array of absolute paths or a path to traverse. This also accepts an object (<entry name> -> <paths> ). It can be a good idea glob these. |
purifyOptions | Pass custom options to PurifyCSS. |
verbose | Set this flag to get verbose output from the plugin. This sets purifyOptions.info , but you can override info separately if you want less logging. |
The plugin does not emit sourcemaps even if you enable
sourceMap
option on loaders!
ISC.
FAQs
PurifyCSS for webpack
The npm package purifycss-webpack receives a total of 3,220 weekly downloads. As such, purifycss-webpack popularity was classified as popular.
We found that purifycss-webpack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.