Browse Source

fix(dev) make sure each bundle analysis report gets its own file

master
Saúl Ibarra Corretgé 3 years ago
parent
commit
ea8ed8aa84
1 changed files with 44 additions and 5 deletions
  1. 44
    5
      webpack.config.js

+ 44
- 5
webpack.config.js View File

@@ -31,6 +31,22 @@ function getPerformanceHints(size) {
31 31
     };
32 32
 }
33 33
 
34
+/**
35
+ * Build a BundleAnalyzerPlugin plugin instance for the given bundle name.
36
+ */
37
+function getBundleAnalyzerPlugin(name) {
38
+    if (!analyzeBundle) {
39
+        return [];
40
+    }
41
+
42
+    return [ new BundleAnalyzerPlugin({
43
+        analyzerMode: 'disabled',
44
+        generateStatsFile: true,
45
+        statsFilename: `${name}-stats.json`
46
+    }) ];
47
+}
48
+
49
+
34 50
 // The base Webpack configuration to bundle the JavaScript artifacts of
35 51
 // jitsi-meet such as app.bundle.js and external_api.js.
36 52
 const config = {
@@ -160,11 +176,6 @@ const config = {
160 176
         sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
161 177
     },
162 178
     plugins: [
163
-        analyzeBundle
164
-            && new BundleAnalyzerPlugin({
165
-                analyzerMode: 'disabled',
166
-                generateStatsFile: true
167
-            }),
168 179
         detectCircularDeps
169 180
             && new CircularDependencyPlugin({
170 181
                 allowAsyncCycles: false,
@@ -196,6 +207,8 @@ module.exports = [
196 207
             'app.bundle': './app.js'
197 208
         },
198 209
         plugins: [
210
+            ...config.plugins,
211
+            ...getBundleAnalyzerPlugin('app'),
199 212
             new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
200 213
         ],
201 214
         performance: getPerformanceHints(4 * 1024 * 1024)
@@ -204,6 +217,10 @@ module.exports = [
204 217
         entry: {
205 218
             'alwaysontop': './react/features/always-on-top/index.js'
206 219
         },
220
+        plugins: [
221
+            ...config.plugins,
222
+            ...getBundleAnalyzerPlugin('alwaysontop')
223
+        ],
207 224
         performance: getPerformanceHints(400 * 1024)
208 225
     }),
209 226
     Object.assign({}, config, {
@@ -211,6 +228,8 @@ module.exports = [
211 228
             'dial_in_info_bundle': './react/features/invite/components/dial-in-info-page'
212 229
         },
213 230
         plugins: [
231
+            ...config.plugins,
232
+            ...getBundleAnalyzerPlugin('dial_in_info'),
214 233
             new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
215 234
         ],
216 235
         performance: getPerformanceHints(500 * 1024)
@@ -219,24 +238,40 @@ module.exports = [
219 238
         entry: {
220 239
             'do_external_connect': './connection_optimization/do_external_connect.js'
221 240
         },
241
+        plugins: [
242
+            ...config.plugins,
243
+            ...getBundleAnalyzerPlugin('do_external_connect')
244
+        ],
222 245
         performance: getPerformanceHints(5 * 1024)
223 246
     }),
224 247
     Object.assign({}, config, {
225 248
         entry: {
226 249
             'flacEncodeWorker': './react/features/local-recording/recording/flac/flacEncodeWorker.js'
227 250
         },
251
+        plugins: [
252
+            ...config.plugins,
253
+            ...getBundleAnalyzerPlugin('flacEncodeWorker')
254
+        ],
228 255
         performance: getPerformanceHints(5 * 1024)
229 256
     }),
230 257
     Object.assign({}, config, {
231 258
         entry: {
232 259
             'analytics-ga': './react/features/analytics/handlers/GoogleAnalyticsHandler.js'
233 260
         },
261
+        plugins: [
262
+            ...config.plugins,
263
+            ...getBundleAnalyzerPlugin('analytics-ga')
264
+        ],
234 265
         performance: getPerformanceHints(5 * 1024)
235 266
     }),
236 267
     Object.assign({}, config, {
237 268
         entry: {
238 269
             'close3': './static/close3.js'
239 270
         },
271
+        plugins: [
272
+            ...config.plugins,
273
+            ...getBundleAnalyzerPlugin('close3')
274
+        ],
240 275
         performance: getPerformanceHints(128 * 1024)
241 276
     }),
242 277
 
@@ -248,6 +283,10 @@ module.exports = [
248 283
             library: 'JitsiMeetExternalAPI',
249 284
             libraryTarget: 'umd'
250 285
         }),
286
+        plugins: [
287
+            ...config.plugins,
288
+            ...getBundleAnalyzerPlugin('external_api')
289
+        ],
251 290
         performance: getPerformanceHints(35 * 1024)
252 291
     })
253 292
 ];

Loading…
Cancel
Save