-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
extends
in defineConfig
#8964
Comments
Can't you just do a merge? import { common } from './common.config'
export default defineConfig({
...common,
{
// other config
}
}) Then you can selectively override things. The obvious complexity with |
Using object spread syntax would overwrite fields, e.g. const commonConfig = {
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src'),
},
]
}
}
export default defineConfig({
...commonConfig,
resolve: {
alias: [...]
}
}) The whole |
Right, you'd need to do more effort: const commonConfig = {
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src'),
},
]
}
}
export default defineConfig({
...commonConfig,
resolve: {
alias: [...commonConfig.alias, ...newAliases]
}
}) Not clean, for sure. I have not looked, but how does Vite implement merging under the hood? Is it just something like https://www.npmjs.com/package/deepmerge? I wonder if that would work for you, if the Vite team doesn't want to expose and document |
#8999 It seems that Vite now documents |
|
Description
I'd like to add a field
extends
fordefineConfig
like this:It would help us unify and simplify the vite config files in our projects.
Suggested solution
The semantics of
extends
can be identical tomergeConfig
.We can allow using package name directly in
extends
for convenience.Alternative
mergeConfig
Adding
extends
field is more simple and constrained than letting users usemergeConfig
directly in their config files. Besides,mergeConfig
is an undocumented API.abstract over vite
defineConfig
Wrap around vite like:
It works but we think it's better to add this ability directly to vite rather than wrap it.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: