grunt-filesize

A Grunt plugin for logging filesize.

grunt-filesize

A Grunt plugin for logging filesize.

modify your grunt.js file by adding the following line:

grunt.loadNpmTasks('grunt-filesize');

Then add some configuration for the plugin like so:

grunt.initConfig({
  ...
  filesize: {
    base: {
      files: [
        {expand: true, cwd: 'build', src: ['*.css', '*.js']}
      ],
      options: {
        ouput: [
          {
            stdout: true
          },
          {
            path: "output/file/{now:MMMDDYYYY}.csv",
            format: {filename},{size:0,0}
          },
          {
            path: "output/file/filename.txt",
            format: "{now:YYYY/MM/DD} {filename} {mb} mb",
            append: true
          }
        ]
      }
    }
  },
  ...
});

Specify the format of the file to be output.

Specify the format in the placeholder if you have set in the String. Possible placeholder is as follows.

placeholdertypedescription
fullpathstringfull absolute file path
filenamestringfile name
basenamestringlast portion of a path
sizenumberfile size (bytes)
kbnumberfile size (kb)
mbnumberfile size (mb)
nowdateoutput date

Placeholder I enclosed in curly braces. It is possible to specify the color and format. Color is valid only if the standard output.

e.g.

{property,color:format}

Color specification the contents of the colors can be specified. Format specification can be specified only in the date type or numeric type. Date type format use the moment. Number type format use the numeral.

Output options is specify the output destination and format.

Possible property is as follows.

plopertytypedescription
stdoutbooloutput to console. If true is specified, the path property is ignored.
pathstringoutput file name. You can specify the place holder.
appendboolAppend the results to output file.
formatstring,functionSame format option

Obsolete.

Setting the 'reporting' option will generate a properties file on the given path for each file measured, you can use those in the Jenkins Plot plugin or other ways.

e.g.

options: {
  reportingfunction (filePath) {
    return 'target/grunt/filesize/' + filePath + '.txt';
  }
},