Browse Source

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

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

Loading…
Cancel
Save