-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix: normalize vite config resolution #24369
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
fix: normalize vite config resolution #24369
Conversation
Thanks for taking the time to open a PR!
|
e8a07a4
to
cf3ca15
Compare
@@ -21,19 +21,6 @@ export default defineConfig({ | |||
devServer: { | |||
bundler: 'vite', | |||
framework: 'vue', | |||
viteConfig: { | |||
optimizeDeps: { |
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.
Vite 3.0 made many improvements for handling unoptimized deps. The problem this was fixing was reloads that would occur mid-test when Vite was scanning deps. From my testing, this no longer happens and we can safely remove this list.
}, | ||
plugins: [ | ||
Cypress(config, vite), | ||
CypressInspect(config), |
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.
A user can push this plugin in themselves, doesn't really make sense for us to support this, especially since it's use is not documented.
webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { | ||
if (removeList.includes(plugin.constructor.name)) { | ||
/* eslint-disable no-console */ | ||
console.warn(`[@cypress/webpack-dev-server]: removing ${plugin.constructor.name} from configuration.`) |
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.
We modify the webpack config pretty heavily but don't console log for every tweak we make. Removing this log so as to clean up the terminal output.
@@ -183,12 +146,5 @@ export async function makeWebpackConfig ( | |||
|
|||
debug('Merged webpack config %o', mergedConfig) | |||
|
|||
if (process.env.WEBPACK_PERF_MEASURE) { |
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.
We don't have this documented, and it doesn't work for many Webpack 5 apps so it's getting removed.
} | ||
|
||
const finalConfig = vite.mergeConfig( | ||
resolvedOverrides, | ||
makeCypressViteConfig(config, vite), |
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 used to be swapped, but we don't want users overriding our base config. This makes it so our vite config takes precedence (same as how we handle Webpack config in webpack-dev-server).
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.
I tested this and can confirm that if I provide a viteConfig
property in my Cypress config that my vite.config.ts
file is not merged into the resolved config 👍🏻
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.
👍
User facing changelog
vite.config.{js,ts}
will no longer be sourced whencomponent.devServer.viteConfig
is provided in the project's Cypress configAdditional details
This change brings the vite-dev-server config resolution inline with webpack-dev-server which was deemed to be the proper resolution of the config. With this change, we will no longer source the project's Vite config if they have provided a
viteConfig
property in their Cypresscomponent.devServer
config.The previous behavior was confusing when dealing with edge-cases. If a user happened to
require
their Vite Config in there Cypress config and returned the full config, we would still source their vite config which could potentially end up double merging and duplicating plugins.Steps to test
See the
Test code to reproduce
in the original issue.How has the user experience changed?
Screen.Recording.2022-10-24.at.3.52.43.PM.mov
NOTE: Before merging, during squash add
BREAKING CHANGE
to footer messagePR Tasks
TODO: Figure out what branch to target, this will be a breaking change but
v11
branch already exists and we don't want those changes until v12.cypress-documentation
?type definitions
?