-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support passing inline Astro config to getViteConfig() #10963
Conversation
🦋 Changeset detectedLatest commit: d81b459 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
I have mixed feelings about this one. I was planning to use this function for the container APIs, which will also accept a config. If this function also accepts a config, it would break the compatibility. Why do we pass the inline config instead of user config? Why isn't this validated? |
I’m not sure I understand the first question here? We currently document using In this case, @HiDeoo is working on a refactor to use
It sounds like we may be somewhat overloading this one function? If it’s already used publicly for Vitest support, should we maybe not split it into some more dedicated helpers rather than also trying to use it for the container API? In your case, I’d think we could refactor to a shared internal function that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems great to me, we do this a bunch already ourselves in our test utils, so feels fair that users would also want it. I don't have the context that Ema has, so happy to defer to him if there's something I'm missing here.
I checked the source code, and eventually, the configuration is merged and validated, so it's all good. However, |
Hmm, are you sure? |
I suppose I'll have to create a new function just for the container APIs then. |
Changes
Adds support for passing an inline Astro configuration object to
getViteConfig()
If you are using
getViteConfig()
to configure the Vitest test runner, you can now pass a second argument to control how Astro is configured. This makes it possible to configure unit tests with different Astro options when using Vitest’s workspaces feature.Testing
Applied as a patch in Starlight and tested using i18n features in a unit test. It worked as expected.
Docs
Docs PR: withastro/docs#8192