react-ssr-template icon indicating copy to clipboard operation
react-ssr-template copied to clipboard

QUESTION: route based package chunking

Open ahmetkuslular opened this issue 8 months ago • 2 comments

hi,

The project is great, and I want to thank you first.

I'm working on a performance-focused project, and I want to chunk and separate route-based packages.

vendor: {
          test: /[\\/]node_modules[\\/]/,
          enforce: true,
          chunks: 'all',
          name(module: any) {
            const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];

            switch (packageName) {
              case 'react':
              case 'react-dom':
              case 'scheduler':
              case 'object-assign':
                return 'react';
              case 'path-to-regexp':
              case 'uuid':
                return 'rarely';
              default:
                return 'vendor';
            }
          },
        },

I want to separate them like the structure here, such as homeVendor, usersVendor, etc., and load only that vendor on the relevant page. Separating them is not a problem, but how can I decide which vendor to load on which route? Is it possible to do something like this?

ahmetkuslular avatar Oct 18 '23 17:10 ahmetkuslular