feat: support advanced entrypoints
Description 📖
This change adds support for more advanced entrypoints:
- Entrypoints with custom names that don't match the file name
- CSS-only entrypoints
Example config for custom names:
{
build: {
rollupOptions: {
input: {
'custom-name': '/some-other-file.js'
}
}
}
}
Example config for CSS only entrypoint:
{
build: {
rollupOptions: {
input: {
'my-style': '/some-style.scss'
}
}
}
}
Background 📜
At GitLab we have entrypoints that don't necessarily match the filenames. This is due to how we change the entrypoints based on the target release: community edition (CE) or enterprise (EE). EE entrypoints are resolved outside of the sourceCodeDir and thus don't match exactly the filename. Also, we use special names for those: pages/foo/bar/index.js will get a name pages.foo.bar. As you can see it can not be directly matched to the filename. That's why we need to respect the name property stored in the manifest and use it instead or the actual filename to resolve an asset.
The same thing applies to the stylesheets, we could have different name for these. So we have to resolve CSS entrypoints using names property, which as added in https://github.com/vitejs/vite/pull/19912 and released in https://github.com/vitejs/vite/releases/tag/v7.0.0-beta.0.
The Fix 🔨
We fix the issue by using name and names property for entries with isEntry field. For such entries we create new records in the manifest with name (or each key in names) used as a primary key.