Webpack bundle analyzer plugin doesn't start

default discord avatar
Rick | Byont Labs
2 months ago

For unknown reasons the browsers sometimes loads a payload bundle of 38mb.


I want to analyze this with webpack-bundle-analyzer but nothing happens if I add this as a plugin. Its like it doesnt run..?


Though I can see in the debugger that it is instantiated.



payload.config.ts


const mockModulePath = path.resolve(__dirname, 'mocks/serverModule.js');


// some config and then
webpack: (config) => ({
      plugins: [...config.plugins, plugin],
      ...config,
      resolve: {
        ...config.resolve,
        alias: {
          BundleAnalyzerPlugin: mockModulePath,
          [path.resolve(__dirname, 'bundleAnalyzer')]: mockModulePath
        }
      }
    })


bundleAnalyzer.ts



import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
const plugin = new BundleAnalyzerPlugin({});

export default plugin;


Figured it out, ...config was overwriting my plugin 🙂

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!

    Star

    Connect with the Payload Community on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.