`extends` in `defineConfig`
See original GitHub issueDescription
I’d like to add a field extends
for defineConfig
like this:
import commonConfig from '@company/vite-config-common'
export default defineConfig({
extends: [commonConfig]
})
It would help us unify and simplify the vite config files in our projects.
Suggested solution
The semantics of extends
can be identical to mergeConfig
.
We can allow using package name directly in extends
for convenience.
Alternative
-
mergeConfig
Addingextends
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:
// @mycompany/wrapped-vite/index.ts
import { mergeConfig, defineConfig } from 'vite'
const commonConfig = ...
export const defineConfig: typeof defineConfig = (...args) => mergeConfig(commonConfig, defineConfig(...args))
// user-project/vite.config.ts
import { defineConfig } from '@mycompany/wrapped-vite'
export default defineConfig({...})
It works but we think it’s better to add this ability directly to vite rather than wrap it.
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Configuring Vite
Configuring Vite #. When running vite from the command line, Vite will automatically try to resolve a config file named vite.config.js inside project...
Read more >How to extend cypress.json config to other configuration files?
Cypress plugin that adds "extends" support to the configuration file. ... const { defineConfig } = require('cypress') const baseConfig ...
Read more >Writing a Plugin - Cypress Documentation
The Plugins API allows you to hook into and extend Cypress behavior. ... const { defineConfig } = require('cypress') module.exports = defineConfig({ ...
Read more >Configuring Windi CSS
defineConfig is a bypass function with type hints, which means you can also omit it if you don't need the autocompletion/typecheck. windi.config.js. export ......
Read more >Configuring Vitest
VITEST or mode property on defineConfig (will be set to test ... When using a separate vitest.config.js , you can also extend Vite's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
mergeConfig
and many exposed APIs are always public, but we expose a lot of APIs to fit in the docs so it only shows the commonly used ones. I think usingmergeConfig
is the way to go here. If we implementextends
it’ll very likely be the same asmergeConfig
, and it’s better to have one way of doings things. Plus doing it in-code makes it easier to reason how data is passed around.https://github.com/vitejs/vite/pull/8999 It seems that Vite now documents
mergeConfig
as an public API. Though I still don’t want users of my common config usesmergeConfig
directly, this feature request is more unnecessary now.😅