A GruntJS plugin that displays the size of files


Display the size of files

If you haven't used grunt before, be sure to check out the Getting Started guide.

From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:

npm install grunt-plugin-size --save-dev

Once that's done, add this line to your project's Gruntfile:


If the plugin has been installed correctly, running grunt --help at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a devDependency, which ensures that it will be installed whenever the npm install command is run.

Run this task with the grunt size command.

This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation. [multi task]:

This task displays the sizes of files.

Type: boolean Default: true

This option sets whether the file size should be displayed in human-readable sizes (GiB, MiB, KiB) or in raw bytes.

Typical configuration is simply to identify a collection of files to be listed:

size: {
    app: ['build/*.*']

This configuration would result in:

build/index.html     5.8 KiB
build/app.min.css   24.0 KiB
build/app.min.js   104.8 KiB

If the log needed to be parsed by a script, the size plugin might be configured to output in a non-human-readable format:

size: {
    app: ['build/*.*'],
    options: {
        human: false

This configuration would result in:

build/index.html     5936 B
build/app.min.css   24537 B
build/app.min.js   107302 B