Skip to content

Commit

Permalink
feat: control plugin load order
Browse files Browse the repository at this point in the history
  • Loading branch information
manchenkoff committed Sep 14, 2024
1 parent 136b5c8 commit fa1e46d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export const defaultModuleOptions: ModuleOptions = {
allow404WithoutAuth: true,
},
logLevel: 3,
appendPlugin: false,
}
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default defineNuxtModule<ModuleOptions>({
level: sanctumConfig.logLevel,
})

addPlugin(resolver.resolve('./runtime/plugin'))
addPlugin(resolver.resolve('./runtime/plugin'), { append: sanctumConfig.appendPlugin })
addImportsDir(resolver.resolve('./runtime/composables'))

if (sanctumConfig.globalMiddleware.enabled) {
Expand Down
7 changes: 7 additions & 0 deletions src/runtime/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,11 @@ export interface ModuleOptions {
* @default 3
*/
logLevel: number
/**
* Determines whether to append the plugin to the Nuxt application.
* Be default, Nuxt prepends the plugin to load it before the application modules.
* @default false
* @see https://nuxt.com/docs/api/kit/plugins#options
*/
appendPlugin: boolean
}

0 comments on commit fa1e46d

Please sign in to comment.