Add "presets" option to Vite config
See original GitHub issueIs your feature request related to a problem? Please describe. Currently, plugins cannot add other plugins. #2484
Describe the solution you’d like
Add presets
array option, which calls mergeConfig
on each preset before plugins are processed.
The user config is merged after any presets.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 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 >Using Plugins - Vite
Using Plugins #. Vite can be extended using plugins, which are based on Rollup's well-designed plugin interface with a few extra Vite-specific options....
Read more >Building for Production - Vite
If you are deploying your project under a nested public path, simply specify the base config option and all asset paths will be...
Read more >Plugin API - Vite
Users will add plugins to the project devDependencies and configure them ... plugins also accepts presets including several plugins as a single element....
Read more >Building for Production - Vite
defaults and supports es6-module and supports es6-module-dynamic-import, ... You can specify custom targets via the build.target config option, ...
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
What @bluwy pointed out: Vite actually accepts nested array of plugins so you can do:
This is essentially what
@vitejs/plugin-legacy
is doing (it contains 3 internal sub-plugins). I’m not sure if the concept of presets is really necessary when you can just do that.FWIW, a preset can also be written as a plugin. It can add other plugins by having the preset function to return an array of plugins instead, e.g. https://gist.github.com/bluwy/18b8d103cea5f823a95c4ce39d36a048. Vite will flatten the plugins before resolving them.
Though it doesn’t look as simple as just exporting a config object/function.