Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
feat: nuxt Add motion imports and autoImportMotion option to module
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Jan 5, 2024
1 parent 9a3dd9d commit 39e4bdb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { addComponent, defineNuxtModule } from '@nuxt/kit'
import { addComponent, addImports, defineNuxtModule } from '@nuxt/kit'

export interface ModuleOptions {
autoImportComponents?: boolean
autoImportMotion?: boolean
prefix?: string
}

Expand All @@ -23,13 +24,24 @@ const motionComponents = [
'PresenceGroup',
]

const motionImports = [
'animate',
'timeline',
'stagger',
'spring',
'glide',
'inView',
'scroll',
]

export default defineNuxtModule<ModuleOptions>({
meta: {
name: '@oku-ui/motion-nuxt',
configKey: 'motion',
},
defaults: {
autoImportComponents: true,
autoImportMotion: true,
},
setup(options, nuxt) {
// const resolver = createResolver(import.meta.url)
Expand All @@ -47,6 +59,15 @@ export default defineNuxtModule<ModuleOptions>({
})
}

if (options.autoImportMotion) {
motionImports.forEach((motion) => {
addImports({
from: '@oku-ui/motion',
name: motion,
})
})
}

// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
// addPlugin(resolver.resolve('./runtime/plugin'))
},
Expand Down

0 comments on commit 39e4bdb

Please sign in to comment.