css-purifier
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

CSS Purifier

Vite Plugin for CSS Size Reduction

Installation

npm i css-purifier --save-dev

Usage

In your Vite configuration, import the plugin:

import { cssPurifier } from 'css-purifier';

Then invoke the plugin:

plugins: [
  cssPurifier(pureCssConfig),
]

Plugin Configuration

The plugin accepts a JavaScript object of the following format:

  • input - string. The name of the file you want to purify.
  • output - string. The name of the file that will be created from the input.
  • selectors - (string|RegExp)[]. Selectors that need to be retained from input to output. For example, ['.btn']. To indicate that a selector can be in any part of the selector, you can use this approach: selectors: ['.some-class', /popup/]. This will work on any classes that contain the word popup.
  • shouldPrintOutput - boolean. Whether to display the final content in debug mode.
  • shouldPrintSelectors - boolean. Whether to display selectors in debug mode.

Example

cssPurifier({
    input: 'node_modules/bootstrap/min-style.css',
    output: 'assets/styles/cleaned-bootstrap.css',
    selectors: [
        /popup/, '.heading',
    ],
    shouldPrintOutput: false,
    shouldPrintSelectors: true,
})

Readme

Keywords

none

Package Sidebar

Install

npm i css-purifier

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

4.18 kB

Total Files

4

Last publish

Collaborators

  • loot_js