A grunt plugin to get CSS statistics for your project.
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');
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']
}
}
},
Type: Boolean
, Default value: false
Turns on PostCSS' safe mode.
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'],
},
},
});
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'],
},
},
});
MIT
- 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).