Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add example of 'alphabetical' plugin numbering #20930

Merged
merged 1 commit into from May 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/2.guide/2.directory-structure/1.plugins.md
Expand Up @@ -67,20 +67,24 @@ If you are using an object-syntax plugin, the properties may be statically analy

## Plugin Registration Order

You can control the order in which plugins are registered by prefixing a number to the file names.
You can control the order in which plugins are registered by prefixing with 'alphabetical' numbering to the file names.

For example:

```bash
plugins/
| - 1.myPlugin.ts
| - 2.myOtherPlugin.ts
| - 01.myPlugin.ts
| - 02.myOtherPlugin.ts
```

In this example, `2.myOtherPlugin.ts` will be able to access anything that was injected by `1.myPlugin.ts`.
In this example, `02.myOtherPlugin.ts` will be able to access anything that was injected by `01.myPlugin.ts`.

This is useful in situations where you have a plugin that depends on another plugin.

::alert{type=info icon=πŸ’‘}
In case you're new to 'alphabetical' numbering, remember that filenames are sorted as strings, not as numeric values. For example, `10.myPlugin.ts` would come before `2.myOtherPlugin.ts`. This is why the example prefixes single digit numbers with `0`.
::

## Using Composables Within Plugins

You can use [composables](/docs/guide/directory-structure/composables) within Nuxt plugins:
Expand Down