Socket
Socket
Sign inDemoInstall

css-purifier

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-purifier

Vite plugin for purification css files


Version published
Weekly downloads
11
increased by120%
Maintainers
1
Weekly downloads
 
Created
Source

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,
})

FAQs

Package last updated on 19 May 2024

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