@@ -26,6 +26,10 @@ function resolveDefaultSizes(defaultSizes) {
2626 return defaultSizes === 'compressed' ? 'gzip' : defaultSizes ;
2727}
2828
29+ function resolveCompressedSizeLabel ( compressionAlgorithm ) {
30+ return { gzip : 'Gzipped' , brotli : 'Brotli' } [ compressionAlgorithm ] ;
31+ }
32+
2933module . exports = {
3034 startServer,
3135 generateReport,
@@ -43,10 +47,11 @@ async function startServer(bundleStats, opts) {
4347 logger = new Logger ( ) ,
4448 defaultSizes = 'parsed' ,
4549 excludeAssets = null ,
46- reportTitle
50+ reportTitle,
51+ compressionAlgorithm = 'gzip'
4752 } = opts || { } ;
4853
49- const analyzerOpts = { logger, excludeAssets} ;
54+ const analyzerOpts = { logger, excludeAssets, compressionAlgorithm } ;
5055
5156 let chartData = getChartData ( analyzerOpts , bundleStats , bundleDir ) ;
5257
@@ -64,6 +69,7 @@ async function startServer(bundleStats, opts) {
6469 title : resolveTitle ( reportTitle ) ,
6570 chartData,
6671 defaultSizes : resolveDefaultSizes ( defaultSizes ) ,
72+ compressedSizeLabel : resolveCompressedSizeLabel ( compressionAlgorithm ) ,
6773 enableWebSocket : true
6874 } ) ;
6975 res . writeHead ( 200 , { 'Content-Type' : 'text/html' } ) ;
@@ -130,13 +136,14 @@ async function generateReport(bundleStats, opts) {
130136 openBrowser = true ,
131137 reportFilename,
132138 reportTitle,
139+ compressionAlgorithm = 'gzip' ,
133140 bundleDir = null ,
134141 logger = new Logger ( ) ,
135142 defaultSizes = 'parsed' ,
136143 excludeAssets = null
137144 } = opts || { } ;
138145
139- const chartData = getChartData ( { logger, excludeAssets} , bundleStats , bundleDir ) ;
146+ const chartData = getChartData ( { logger, excludeAssets, compressionAlgorithm } , bundleStats , bundleDir ) ;
140147
141148 if ( ! chartData ) return ;
142149
@@ -145,6 +152,7 @@ async function generateReport(bundleStats, opts) {
145152 title : resolveTitle ( reportTitle ) ,
146153 chartData,
147154 defaultSizes : resolveDefaultSizes ( defaultSizes ) ,
155+ compressedSizeLabel : resolveCompressedSizeLabel ( compressionAlgorithm ) ,
148156 enableWebSocket : false
149157 } ) ;
150158 const reportFilepath = path . resolve ( bundleDir || process . cwd ( ) , reportFilename ) ;
@@ -160,9 +168,10 @@ async function generateReport(bundleStats, opts) {
160168}
161169
162170async function generateJSONReport ( bundleStats , opts ) {
163- const { reportFilename, bundleDir = null , logger = new Logger ( ) , excludeAssets = null } = opts || { } ;
171+ const { reportFilename, bundleDir = null , logger = new Logger ( ) , excludeAssets = null ,
172+ compressionAlgorithm = 'gzip' } = opts || { } ;
164173
165- const chartData = getChartData ( { logger, excludeAssets} , bundleStats , bundleDir ) ;
174+ const chartData = getChartData ( { logger, excludeAssets, compressionAlgorithm } , bundleStats , bundleDir ) ;
166175
167176 if ( ! chartData ) return ;
168177
0 commit comments