Skip to content

Commit fd224e4

Browse files
committed
task(settings): Improve webpack chunking
Because: - We can get better cache performance if things that don't change often are chunked into their own packages - We can getter optimized network behavior with HTTP/2 and modern browsers by splitting up js files this way, ie multiple files can be downloaded concurrently. This Commit: - Creates a chunk for react and reach router called the 'presentation' chunk - Creates a chunk for large utils like moment or ua-parser called utils - Creates a chunk for observability libs like glean or sentry - Creates a chunk for network libs like apollo and gql
1 parent 7d23742 commit fd224e4

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

packages/fxa-settings/config/webpack.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,30 @@ module.exports = function (webpackEnv) {
305305
// This is only used in production mode
306306
new CssMinimizerPlugin(),
307307
],
308+
splitChunks: isEnvProduction ? {
309+
cacheGroups: {
310+
presentation: {
311+
test: /[\\/]node_modules[\\/]react|react-dom|@reach|@fluent[\\/]/,
312+
name: 'presentation-chunk',
313+
chunks: 'all',
314+
},
315+
utils: {
316+
test: /[\\/]node_modules[\\/]moment|lodash|ua-parser-js[\\/]/,
317+
name: 'utils-chunk',
318+
chunks: 'all',
319+
},
320+
observability: {
321+
test: /([\\/]node_modules[\\/]@sentry.*[\\/])|([\\/]glean[\\/])/,
322+
name: 'observability-chunk',
323+
chunks: 'all',
324+
},
325+
networking: {
326+
test: /([\\/]node_modules[\\/]graphql|graphql-tag|@apollo.*[\\/])|([\\/]fxa-auth-client[\\/])/,
327+
name: 'networking-chunk',
328+
chunks: 'all',
329+
},
330+
},
331+
} : {}
308332
},
309333
resolve: {
310334
// This allows you to set a fallback for where webpack should look for modules.

0 commit comments

Comments
 (0)