-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Labels
p2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)
Description
Describe the bug
When one imports an asset (let's say .svg) using import.meta.glob(..., { eager: true, import: 'default' })
new path will be inlined in a const
and then this const get's tree-shaked/optimized, corresponding asset is not excluded from the final build.
It's expected that no unused assets, especially heavy ones like fonts and images, are not included in final build.
Reproduction
https://github.com/BerkliumBirb/vite-broken-tree-shaking
Steps to reproduce
- clone repo
npm i
npm run build
- check out
dist/
Expected to only have "dist/blue-XXX.svg", but "dist/red-XXX.svg" is also there yet not reachable from code.
System Info
npmPackages:
vite: ^6 => 6.3.3
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
p2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)