Skip to content

Commit

Permalink
docs: create plugin hook
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Apr 24, 2024
1 parent 9d6a152 commit 7099e12
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/guide/api-vite-environment.md
Expand Up @@ -579,6 +579,28 @@ The hook can choose to:
}
```
### Per-environment Plugins
There is a new `create` hook that plugins can define to lazily create per-environment plugins.
```js
function perEnvironmentPlugin() {
return {
name: 'per-environment-plugin',
// Return a plugin, an array, a Promise, or a falsy value for each environment
create(environment: Environment) {
if (!passesCondition(environment)) {
return undefined
}
return [
createEnvironmentPlugin(environment),
otherPlugin(environment)
]
}
}
}
```
## `ModuleRunner`
A module runner is instantiated in the target runtime. All APIs in the next section are imported from `vite/module-runner` unless stated otherwise. This export entry point is kept as lightweight as possible, only exporting the minimal needed to create runners in the
Expand Down

0 comments on commit 7099e12

Please sign in to comment.