Skip to content
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

Full control of build filename in library mode #3585

hronro opened this issue May 29, 2021 · 1 comment

Full control of build filename in library mode #3585

hronro opened this issue May 29, 2021 · 1 comment


Copy link

@hronro hronro commented May 29, 2021

Clear and concise description of the problem

? `${libOptions.fileName || pkgName}.${output.format || `es`}.js`

Currently vite always append .es.js in the end of filename in library mode, but there should be a way to let users fully control the filenames.

Suggested solution

Add another options in LibraryOptions like fullyControlledFileName:

interface LibraryOptions {
  // ...
  fileName?: string;
  fullyControlledFileName?: string | (format: LibraryFormats) => string;

fullyControlledFileName should have higher priority than fileName, so if fullyControlledFileName is not undefined, vite should ignore the fileName option.


Another way is changing the current behavior of the option fileName to make user fully control how the file name is generated, but this would be a breaking change to those who relay on the current file naming strategy.

Copy link

@sodatea sodatea commented May 30, 2021

We've discussed this issue in a team meeting before. Instead of adding a new option, I think letting fileName accept a function would suffice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants