grunt-cssstats
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;
The "cssstats" task
Overview
In your project's Gruntfile, add a section named cssstats
to the data object passed into grunt.initConfig()
.
grunt;
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;
Custom Options
In order to handle invalid CSS, you can set options.safe
to true
. This will turn on
PostCSS' safe mode.
grunt;
License
MIT
Thanks to the following
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Crafted with <3 by John Otander (@4lpine).