Installation
PurifyCSS can be used as a standalone library, a command-line tool, or integrated into your build process with tools like Grunt, Gulp, or Webpack.
Standalone Library
To use PurifyCSS programmatically in your Node.js project, install it as a development dependency:
npm install --save-dev purify-css
Then, you can require and use it in your scripts:
const purify = require('purify-css');
// Or using ES modules
// import purify from 'purify-css';
// ... your code here
Command-Line Interface (CLI)
For direct use in your terminal or in scripts, you can install the CLI tool globally:
npm install -g purify-css
Once installed, you can use the purifycss
command. For more details, see the CLI Reference.
Build Tool Integrations
Integrating PurifyCSS into your build process is the most common and effective way to use it. There are official plugins available for popular build tools:
- Grunt: grunt-purifycss
- Gulp: gulp-purifycss
- Webpack: purifycss-webpack-plugin
For more information on using these plugins, please refer to their respective documentation and the Build Tool Integrations page.