Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bird3-purifycss-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bird3-purifycss-webpack-plugin

BIRD3's PurifyCSS WebPack plugin. Time to clean your styles!

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

PurifyCSS WebPack Plugin

This is a plugin for WebPack that utilizes PurifyCSS to clean your CSS. Its dead simple, but it requires you to be prepared.

So, let's go and clean some style!

Dependencies

  • WebPack must be already installed, so that this plugin can use it's library parts.
  • You should use the extract-text-webpack-plugin - although, you are not enforced to. Without any CSS file being emitted as an asset, this plugin will not do a thing except idle about inside the compiler. You can also use the file plugin to drop a special CSS file into your output folder, but I highly recommend the extract plugin.

Use

First, get it:

npm install --save bird3-purifycss-webpack-plugin

Let's assume you have a basic webpack configuration like so:

var extractor = require("extract-text-webpack-plugin");
module.exports = {
    entry: "app.js",
    output: {
        // ...
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: extractor.loader("style","css") }
        ]
    },
    plugins: [
        new extractor("[name].css")
    ]
}

Now, all we add, is another plugin definition. Please note: Plugins seem to be executed in order, so make sure that this plugin comes after the extract plugin, if you use it.

var extractor = require("extract-text-webpack-plugin");
var purify = require("bird3-purifycss-webpack-plugin");
module.exports = {
    entry: "app.js",
    output: {
        // ...
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: extractor.loader("style","css") }
        ]
    },
    plugins: [
        new extractor("[name].css"),
        new purify({
            basePath: __dirname,
            paths: [
                "app/views/*.html",
                "app/layout/*.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".

Options

This plugin, unlike the original PurifyCSS plugin, provides special features, such as scanning the dependency files and all kinds of files. To configure such behaviours, I will show you the options.

PropertyDescription
basePathThe path from which all the other paths will start. Required.
resolveExtensionsAn array of extensions that should be given to PurifyCSS when determining classes. (defaults to webpack resolve.extensions config)
pathsAn array of globs that reveal all your files. See glob's documentation to see what kind of paths you can pass in this array. Use this array to pass files that won't be known to WebPack.
purifyOptionsPass these options to PurifyCSS. See here. Note: output is always false.

Notes

This plugin is NOT a fork of the offical plugin! Instead, this is it's own. I prefixed it with bird3, since it was created within my BIRD3 project and to make an obvious separation to the offical version.

Keywords

FAQs

Package last updated on 17 Nov 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc