From 81d010a1f525e89df8fad3c90fe33756a6e1fdae Mon Sep 17 00:00:00 2001 From: Luciano Martorella Date: Wed, 19 Jun 2024 12:46:00 +0200 Subject: [PATCH] - Added verboseReport --- tasks/concat.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tasks/concat.js b/tasks/concat.js index 37c9979..bd621d9 100644 --- a/tasks/concat.js +++ b/tasks/concat.js @@ -8,6 +8,16 @@ 'use strict'; +const prettyPrint = num => { + if (num < 1024) { + return `${num} bytes`; + } + if (num < 1024 * 1024) { + return `${(num / 1024).toFixed(1)} kB`; + } + return `${(num / (1024 * 1024)).toFixed(1)} MB`; +} + module.exports = function(grunt) { // Internal lib. @@ -25,7 +35,8 @@ module.exports = function(grunt) { process: false, sourceMap: false, sourceMapName: undefined, - sourceMapStyle: 'embed' + sourceMapStyle: 'embed', + verboseReport: false }); // Normalize boolean options that accept options objects. @@ -115,6 +126,9 @@ module.exports = function(grunt) { sourceMapHelper.add(options.separator); } } + if (options.verboseReport) { + grunt.log.writeln(` bundling ${chalk.cyan(filepath)}, size ${prettyPrint(src.length)}`); + } return src; }).join(options.separator) + footer;