-
-
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
When using getViteConfig, the files listed in setupFiles are loaded twice. #12287
Comments
It seems that there is an issue with a plugin named It looks like the problem can be resolved by modifying the following part. astro/packages/astro/src/core/middleware/vite-plugin.ts Lines 23 to 27 in 9d6bcdb
config(opts, { command }) {
isCommandBuild = command === 'build';
- return opts;
+ return {};
}, https://vite.dev/guide/api-plugin.html#config
In the config, it is recommended to return only the parts you want to change, rather than the entire modified config. |
I'll try to create a PR for the fixes. |
Good catch. Yeah I think we can skip returning anything altogether. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using getViteConfig instead of defineConfig for Vitest, the files listed in setupFiles are loaded twice.
In the Reproducible Example, when you run
npm run test
, you can see thatconsole.log
is output twice as shown below.I am having trouble when there is initialization processing that I want to execute only once before running the tests.
What's the expected result?
Even when using getViteConfig, I want the files listed in setupFiles to be loaded only once.
Link to Minimal Reproducible Example
https://stackblitz.com/github/koyopro/astro-debug/tree/vitest_setup_files?file=tests%2Fsetup.ts
Participation
The text was updated successfully, but these errors were encountered: