vite

Is there any bundle analyzer for vite?


We developed an app in vite and I want to analyze the bundle of app, I found rollup-plugin-analyzer but it did not work for me.


Solution

  • You can use rollup-plugin-visualizer;

    import { visualizer } from "rollup-plugin-visualizer";
    ...
    export default defineConfig({
      ...
      plugins: [
        ...
        visualizer({
          template: "treemap", // or sunburst
          open: true,
          gzipSize: true,
          brotliSize: true,
          filename: "analyse.html", // will be saved in project's root
        }) as PluginOption,
        ...
      ],
      ...
    });