Skip to content

Commit

Permalink
feat(nuxt): add unocss:config hook (#2790)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Jun 26, 2023
1 parent 4295f82 commit 5ae31b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/nuxt3/package.json
Expand Up @@ -11,7 +11,7 @@
"@unocss/core": "link:../../packages/core",
"@unocss/nuxt": "link:../../packages/nuxt",
"@unocss/reset": "link:../../packages/reset",
"nuxt": "^3.3.1",
"nuxt": "^3.6.0",
"unocss": "link:../../packages/unocss"
},
"stackblitz": {
Expand Down
2 changes: 2 additions & 0 deletions packages/nuxt/src/index.ts
Expand Up @@ -63,6 +63,8 @@ export default defineNuxtModule<UnocssNuxtOptions>({
configFile: options.configFile,
}, [], options)

await nuxt.callHook('unocss:config', unoConfig)

if (
isNuxt3()
&& nuxt.options.builder === '@nuxt/vite-builder'
Expand Down
9 changes: 9 additions & 0 deletions packages/nuxt/src/types.ts
Expand Up @@ -87,3 +87,12 @@ export interface UnocssNuxtOptions extends UserConfig {
*/
wind?: boolean | PresetWindOptions
}

declare module '@nuxt/schema' {
interface NuxtHooks {
/**
* When UnoCSS load config completed.
*/
'unocss:config': (config: UserConfig) => void
}
}

0 comments on commit 5ae31b0

Please sign in to comment.