Skip to content

Commit ceca4c2

Browse files
committed
Build: Report compressed sizes in compare_size
Just like it has always worked in Core. This will help with size comparisons between 1.13 & 1.14. After this PR: ``` $ grunt sizer Running "requirejs:js" (requirejs) task Running "uglify:main" (uglify) task >> 1 file created 549 kB → 267 kB Running "compare_size:all" (compare_size) task raw gz Sizes 549319 128757 dist/jquery-ui.js 266710 69612 dist/jquery-ui.min.js Done. ``` Before, only the less interesting `raw` sizes were reported.
1 parent 795b773 commit ceca4c2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Gruntfile.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module.exports = function( grunt ) {
44

5+
const gzip = require( "gzip-js" );
6+
57
// files
68
const coreFiles = [
79
"core.js",
@@ -75,7 +77,15 @@ const compareFiles = {
7577
all: [
7678
"dist/jquery-ui.js",
7779
"dist/jquery-ui.min.js"
78-
]
80+
],
81+
options: {
82+
compress: {
83+
gz: function( contents ) {
84+
return gzip.zip( contents, {} ).length;
85+
}
86+
},
87+
cache: "build/.sizecache.json"
88+
}
7989
};
8090

8191
const htmllintBad = [
@@ -115,8 +125,6 @@ uiFiles.concat( allI18nFiles ).forEach( function( file ) {
115125
} );
116126

117127
uiFiles.forEach( function( file ) {
118-
119-
// TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13
120128
compareFiles[ file ] = [ file, mapMinFile( file ) ];
121129
} );
122130

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"grunt-eslint": "24.0.1",
7575
"grunt-git-authors": "3.2.0",
7676
"grunt-html": "16.0.0",
77+
"gzip-js": "0.3.2",
7778
"load-grunt-tasks": "5.1.0",
7879
"rimraf": "4.4.1",
7980
"selenium-webdriver": "4.18.1",

0 commit comments

Comments
 (0)