1.0.1 • Published 9 years ago

grunt-cssstats v1.0.1

Weekly downloads
20
License
MIT
Repository
github
Last release
9 years ago

grunt-cssstats Build Status

A grunt plugin to get CSS statistics for your project.

Getting Started

This plugin requires Grunt and is a wrapper for https://github.com/jxnblk/css-statistics.

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-cssstats --save-dev

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

grunt.loadNpmTasks('grunt-cssstats');

The "cssstats" task

Overview

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

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

You can analyze the CSS stats for particular builds:

cssstats: {
  dev: {
    options: { safe: true },
    files: {
      'output/cssstats-dev.json': ['app/styles/main.css']
    }
  },
  prod: {
    options: { safe: true },
    files: {
      'output/cssstats.json': ['dist/styles/c.css']
    }
  }
},

Options

options.safe

Type: Boolean, Default value: false

Turns on PostCSS' safe mode.

Usage Examples

Default Options

In this example, the default options won't be able to handle invalid CSS. So, if a source file contains invalid CSS, an error will be raised.

grunt.initConfig({
  cssstats: {
    options: {},
    files: {
      'output/css-stats.json': ['path/to/your.css'],
    },
  },
});

Custom Options

In order to handle invalid CSS, you can set options.safe to true. This will turn on PostCSS' safe mode.

grunt.initConfig({
  cssstats: {
    options: {
      safe: true
    },
    files: {
      'output/css-stats.json': ['path/to/your.css'],
    },
  },
});

License

MIT

Thanks to the following

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Crafted with <3 by John Otander (@4lpine).