-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon Test: Merge viteFinal config into vitest config #29806
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 46743b4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
Sent with 💌 from NxCloud. |
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.
1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
Edit: I think the plugin bit won't work. Still I feel like we need to add a migration note for users who already added custom stuff themselves
|
This limitation is going to hurt us: from https://vite.dev/guide/api-plugin.html#config We can modify the config as much as we want, but any modifications to the plugins array won't have an affect. Internally we make heavy use of adding Vite-specifics via plugins, and it's also the recommended pattern in userland, so this is not an edge case. It means that even with this work here, we're still not getting the actual Storybook Vite configuration into the Vitest runtime. And so I wonder, if it's best to try or not?
|
From what I've been able to observe, most of the |
There might actually be a way around the plugins limitations I explained above. We can't add plugins in the We don't need to do this now, let's ship what we have, but this could be a good solution when working on storybookjs/addon-svelte-csf#213 |
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.
previously we did some special handling for some of the properties, which we still need to do.
Package BenchmarksCommit: No significant changes detected, all good. 👏 |
…custom-vitest-config-support
Closes #29778
What I did
I use the preset apply mechanism to load the viteFinal caonfig value, then merge it into the vitest config
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
I manually verified this by modifying a story with an import that did not exist.
Then adding an alias for this non-existing import in the
main.ts
viteFinal
config.That worked.
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
This PR adds functionality to merge Storybook's viteFinal configuration into the Vitest config, ensuring custom Vite configurations are properly applied during test runs.
mergeConfig
import fromvitest/config
in/code/addons/test/src/vitest-plugin/index.ts
presets.apply('viteFinal')
to load custom Vite configuration from Storybook's main configmergeConfig(viteConfigFromStorybook, config)