mui / mui/material-ui

[docs] Explain in the docs how can we use option 2 in icons (named imports) without increasing the bundle size in Vite

Open
#45,391 8 comments 0 reactions 1 assignee View on GitHub

@siriwatknp is already working on this.

Since Feb 24, 2025.

component: Icon external dependency scope: all components support: docs-feedback
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Related page

https://mui.com/material-ui/guides/minimizing-bundle-size/#option-two-use-a-babel-plugin

Kind of issue

Missing information

Issue description

I'm using Vite + React. For reducing the bundle size, I use option 1 (default imports) as follows:

import SomeIcon from "@mui/material-icons/SomeIcon"

This worked great until the file count and icon count increased. Now I see that more than 290 icons are used in my app and they are all being loaded by Vite. I have no idea why. I searched and it seemed that that maybe changing them to named imports would solve this problem.

So, I visited the docs again. However, I could not find any explanation of whether or not using Option 2 (named imports) is OK with Vite.

So, could you please specify this case in your docs? Are named imports OK with Vite in terms of the bundle size? Or do they increase the bundle size?

Context

No response

Search keywords: vite icon

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.