You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a follow-up of #6779, I'm opening this discussion to find a generic solution.
It would be super useful for plugins to be able to hook into the configuration of other plugins. At least that is the initial problem, but I think some sort of API that plugin authors can use to retrieve a value that could possibly have been modified by other plugins would be great.
For example, given this scenario:
pluginA: offers a foo option in its factory function
pluginB: depends on pluginA and needs foo to be set to overriden-foo-value
Vite could offer an API for pluginB to inform pluginA that foo's value needs to be overriden-foo-value. The main use case for me would be to allow back-end plugins to configure other plugins like Vue. A specific example is how Laravel must inform its users to configure Vue themselves: https://laravel.com/docs/9.x/vite#vue
I could imagine the API being something like this:
// pluginAexportdefaultfunctionpluginA(options?: Options){options={foo: 'default-foo-value',
...options}return{name: 'pluginA',configResolved: ({ pluginOverrides })=>{// Here `pluginOverrides` could contain the overrides defined by some other plugin// and pluginA could chose how to use itoptions.foo=pluginOverrides.pluginA.foo??options.foo// options = { ...options, ...pluginOverrides.pluginA }},// ...}}// pluginBexportdefaultfunctionpluginB(){return{name: 'pluginB',overridePlugins: ()=>({pluginA: {foo: 'overriden-foo-value'}})}}
Vite could call overridePlugins on all registered plugins before anything, so pluginOverrides could be filled in other hooks.
That's just one potential idea, but you get the gist of the initial problem - if you can think of something better, feel free to suggest!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
As a follow-up of #6779, I'm opening this discussion to find a generic solution.
It would be super useful for plugins to be able to hook into the configuration of other plugins. At least that is the initial problem, but I think some sort of API that plugin authors can use to retrieve a value that could possibly have been modified by other plugins would be great.
For example, given this scenario:
foo
option in its factory functionpluginA
and needsfoo
to be set tooverriden-foo-value
Vite could offer an API for
pluginB
to informpluginA
thatfoo
's value needs to beoverriden-foo-value
. The main use case for me would be to allow back-end plugins to configure other plugins like Vue. A specific example is how Laravel must inform its users to configure Vue themselves: https://laravel.com/docs/9.x/vite#vueI could imagine the API being something like this:
Vite could call
overridePlugins
on all registered plugins before anything, sopluginOverrides
could be filled in other hooks.That's just one potential idea, but you get the gist of the initial problem - if you can think of something better, feel free to suggest!
Beta Was this translation helpful? Give feedback.
All reactions