grunt-weightwatchsy

1.0.0 • Public • Published

grunt-weightwatchsy

Grunt task for gathering the file sizes of different asset types over time.

NPM

Build Status Coverage Status Dependency Status

Getting Started

This plugin requires Grunt ~0.4.2

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

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

grunt.loadNpmTasks('grunt-weightwatchsy');

The "weightwatchsy" task

Overview

In your project's Gruntfile, the weightwatchsy task is available to use.

You can run grunt weightwatchsy standalone Or add it to an existing task: grunt.registerTask('test', ['clean', 'weightwatchsy']);

Options

{
  //Prettifies file sizes to readable format
  human: <true>,
  //Path where to save results
  location: <'dist/weightwatchsy.json'>,
  //Sums up assets' sizes per extension type
  aggregate: <['.txt', '.css', '.js', '.png', '.jpg']>,
  /**
   * Allows for grouping asset types e.g.
   * {
   *   text: ['.css', '.js']
   * }
   */
  groups: <{}>,
  /**
   * Allows breaking the build by e.g. stating
   * {
   *   aggregations: {
   *     css: 1000
   *   },
   *   groups: {
   *     text: 20000
   *   },
   *   summary: {
   *     size: 50000,
   *     average: 250
   *   }
   * }
   */
   break: <{
     file: {},
     aggregations: {},
     summary: {}
   }>,
   //Aborts grunt immediately if false and a `break`-condition holds
   warn: <true>,
   //Excludes dependencies by name (from extensions and total size etc.)
   exclusions: <[]>,
   //Variations of files e.g .gz versions of all .js and css files which should be
   //treated separately and not be aggregated all as .gz
   variations: <[]>,
   //Keep history over builds with limit
   history: <{
     enabled: <false>,
     limit: <10>
   }>
}

An example configuration can be found here and if you want to check the options you might want to check the Gruntfile itself.

Developing & Contributing

Developing on the task alone is fairly easy just git clone https://github.com/tdeekens/grunt-weightwatchsy.git then cd grunt-weightwatchsy. From there one has to link the package to itself via npm link && npm link grunt-weightwatchsy which will allow for calling grunt dev. Now just work the task/weightwatchsy.js and check results - feel free to submit a pull-request!

Release History

  • 0.0.1 Initial release
  • 0.0.2 Add conditional breaking of build
  • 0.0.3 Clean up and refactoring
  • 0.0.4 Add support for breaking on summary conditions
  • 0.0.5 Add warn-flag allowing to immediately fail grunt if break-condition holds
  • 0.1.0 Minor version bump - stable enough
  • 0.1.1 Fix breaking build with warn-flag
  • 0.1.2 Add summary of sizes by extensions
  • 0.1.3 Add brief information under summary entry
  • 0.1.4 Add support for explicitly excluding extensions
  • 0.1.5 Fix lodash dependency
  • 0.2.0
    • Add support for variation of files (e.g. compressed assets)
    • Remove support for specifying extensions as in '.jpg' or 'jpg' only '.jpg' accepted now\
  • 0.2.1 Fix breaker getting correct parameters
  • 0.2.2 Export raw sizes per extension as devlish values
  • 0.2.3 Add support for history in builds with limit in length (builds)
  • 1.0.0 Update dependencies and add engine requirements

/grunt-weightwatchsy/

    Package Sidebar

    Install

    npm i grunt-weightwatchsy

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • tdeekens