material-tailwind icon indicating copy to clipboard operation
material-tailwind copied to clipboard

Tree-shaking Material Taiwind

Open saiuttej-b opened this issue 1 year ago • 1 comments

I tried building the project and used "rollup-plugin-visualizer" when building my Vite react project and I see that all the Material Tailwind Components are included in my production build bundle, even if I did not use all the components.

Is there any way to fix it?

saiuttej-b avatar May 30 '24 17:05 saiuttej-b

is it a vite problem or material-tailwind problem? im using vite + material-tailwind in my project and i have the same issue, notice the tree shake is not working either, but it's the same case for flowbite, until i put an adjustment like this in the vite.config.

rollupOptions: {
      treeshake: {
        moduleSideEffects: (id) => {
          return (
            id.includes("flowbite-react")
            || id.includes("material-tailwind/react")
          ) ? false : null;
        },
      },
      ...

supermario12342003 avatar Nov 06 '24 12:11 supermario12342003