Giter Site home page Giter Site logo

purgecss's Introduction

Purgecss

Build Status CircleCi dependencies Status devDependencies Status Codacy Badge Codacy Badge styled with prettier npm license Greenkeeper badge

Purgecss logo

What is purgecss?

When you are building a website, chances are that you are using a css framework like Bootstrap, Materializecss, Foundation, etc... But you will only use a small set of the framework and a lot of unused css styles will be included.

This is where Purgecss comes into play. Purgecss analyzes your content and your css files. Then it matches the selectors used in your files with the one in your content files. It removes unused selectors from your css, resulting in smaller css files.

Documentation

You can find the purgecss documentation on this website.

Getting Started

Installation

npm i --save-dev purgecss

Usage

import Purgecss from 'purgecss'
const purgeCss = new Purgecss({
  content: ['**/*.html'],
  css: ['**/*.css']
})
const result = purgeCss.purge()

With a custom extractor:

import Purgecss from 'purgecss'
import purgeHtml from 'purgecss-from-html'
const purgeCss = new Purgecss({
  content: ['**/*.html'],
  css: ['**/*.css'],
  extractors: [
    {
      extractor: purgeHtml,
      extensions: ['html']
    }
  ]
})
const result = purgeCss.purge()

Build Plugin

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

Purgecss use SemVer for versioning.

Acknowledgment

Purgecss was originally thought as the v2 of purifycss. And because of it, it is greatly inspired by it.
Some of the plugins such as purgecss-webpack-plugin are based on the purifycss plugin.
Below is the list of the purifycss repositories:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Wrong extractor is selected

The extractors needs to be defined from the more specific to the less specific. Meaning that you need to define js extractor after ejs. So the js extractor will not be selected for ejs files.

You can specified extensions like .es.js.

purgecss's People

Contributors

epicallan avatar ffloriel avatar greenkeeper[bot] avatar jounqin avatar jsnanigans avatar macklinu avatar mannil avatar morrislaptop avatar nicholasshirley avatar sunui avatar taylorbryant avatar vrajroham avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.