Skip to content

feat(build): provide names for asset entrypoints #19912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

CyberAP
Copy link
Contributor

@CyberAP CyberAP commented Apr 22, 2025

Description

Add names field to asset entrypoints in manifest.

This allows you to map back your asset-only entrypoints to corresponding files in the bundle. This was not possible previously because asset entrypoints only had file, src and isEntry files, none of which included information about entrypoint name.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change makes sense to me, and the implementation looks good.

Note: For non-CSS assets, the output file name cannot be adjusted based on the name specified in the input option. So in that case, this new property wouldn't be useful, but I think that's fine.

Instead of adding a test in packages/vite/src/node/__tests__/build.spec.ts, could you update the test in

expect(dirFooAssetEntry.file).toMatch('assets/bar-')
?
There's a similar entry for input already so you should be able to add an expect without adding a new entry.
entrypoints.push(['bar.css', path.resolve(__dirname, './dir/foo.css')])

@sapphi-red sapphi-red added p2-nice-to-have Not breaking anything but nice to have (priority) feat: build labels Apr 25, 2025
@CyberAP CyberAP force-pushed the provide-asset-names-in-manifest branch from b48363c to a066578 Compare April 25, 2025 14:12
@CyberAP
Copy link
Contributor Author

CyberAP commented Apr 25, 2025

@sapphi-red done!

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@patak-dev patak-dev modified the milestones: 6.4, 7.0 Apr 28, 2025
@sapphi-red sapphi-red merged commit c4e01dc into vitejs:main May 16, 2025
15 checks passed
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: build p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants