1.0.0 • Published 10 years ago

grunt-css-cleaner v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

grunt-css-cleaner

Clean your unused css classes from your app

Getting Started

This plugin requires Grunt.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-css-cleaner --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-css-cleaner');

The "css_cleaner" task

Overview

In your project's Gruntfile, add a section named css_cleaner to the data object passed into grunt.initConfig().

grunt.initConfig({
  css_cleaner: {
    taskname: {
      options: {
        // Task-specific options go here.
      },
      your_target: {
        // Target-specific file lists and/or options go here.
      }
    }
  },
})

Options

options.appRoot

Type: String Default value: './'

A reference to the root directory where to start the scan for templates/pages for CSS usage

options.writeReport

Type: Boolean|String Default value: false

If the report has to be created, an absolute url and file name must be given. I.e. ./tmp/report.txt

options.templatesPath

Type: Array Default value: ['./']

Specify a list of folders to look for app templates

options.templatesType

Type: Array Default value: ['html']

Specify all the extensions used for template files. i.e. 'html', 'jade'

options.ignore

Type: Array Default value: []

List of files/directories to ignore while scanning for css usage

Default Options

grunt.initConfig({
  css_cleaner: {
    options: {
      appRoot       : "./app/",
      writeReport   : "tmp/junk-css-report.txt",
      templatesPath : ["./app/templates", "./website/templates"],
      templatesType : ["jade", "slim"],
      ignore        : ["./app/images/"]
    },
    files: {
      'app_ui': ['./app/assets/css'],
    },
  },
})

License

Copyright (c) 2014 Paolo Moretti. Licensed under the MIT license.