docs: describe `env` object for nuxt plugins (#22963)

This commit is contained in:
Julien Huang 2023-09-04 10:33:53 +02:00 committed by GitHub
parent d49ea58de0
commit d28189eb58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -61,6 +61,12 @@ export default defineNuxtPlugin({
})
```
You can also use the `env` property to define the environments in which your plugin will run.
- **islands**
- **default**: `true`
- **description**: You can set this value to `false` if you don't want the plugin to run when rendering server-only or island components.
::alert
If you are using an object-syntax plugin, the properties may be statically analyzed in future to produce a more optimized build. So you should not define them at runtime. For example, setting `enforce: process.server ? 'pre' : 'post'` would defeat any future optimization Nuxt is able to do for your plugins.
::