Skip to content

Commit

Permalink
feat: export src
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven committed Dec 18, 2024
1 parent e0c3b15 commit 2722fe0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
80 changes: 41 additions & 39 deletions module/kongponents.nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineNuxtModule, createResolver, /*addComponentsDir, */ useLogger , addComponent } from '@nuxt/kit'
import { kebabCase, pascalCase } from 'scule'
import { defineNuxtModule, createResolver, addComponentsDir, useLogger /*, addComponent */ } from '@nuxt/kit'
// import { kebabCase, pascalCase } from 'scule'

export interface ModuleOptions {
// Define module options here as needed
Expand All @@ -17,44 +17,46 @@ export default defineNuxtModule<ModuleOptions>({

logger.start('Initializing Kongponents')

let componentCount = 0

const allComponents = [
{
name: 'KInput',
filePath: resolver.resolve('../src/components/KInput/KInput.vue'),
},
{
name: 'KButton',
filePath: resolver.resolve('../src/components/KButton/KButton.vue'),
},
]

// Loop through the imported components
for (const c of allComponents) {
addComponent({
name: c.name,
filePath: c.filePath,
global: true,
kebabName: kebabCase(c.name),
pascalName: pascalCase(c.name),
})
// Increment component count
componentCount++
}

logger.success(`Globally registered ${componentCount} components`)
// let componentCount = 0

// const allComponents = [
// {
// name: 'KInput',
// filePath: resolver.resolve('../src/components/KInput/KInput.vue'),
// },
// {
// name: 'KButton',
// filePath: resolver.resolve('../src/components/KButton/KButton.vue'),
// },
// ]

// // Loop through the imported components
// for (const c of allComponents) {
// addComponent({
// name: c.name,
// filePath: c.filePath,
// global: true,
// kebabName: kebabCase(c.name),
// pascalName: pascalCase(c.name),
// })
// // Increment component count
// componentCount++
// }

// logger.success(`Globally registered ${componentCount} components`)

// 🥲 this doesn't work
// addComponentsDir({
// path: resolver.resolve('../src/components/'),
// extensions: ['vue'],
// pattern: '**/*.vue',
// pathPrefix: false,
// prefix: '',
// global: true,
// })

// logger.success('Globally registered all Kongponents')
addComponentsDir({
path: resolver.resolve('../src/components/'),
extensions: ['vue'],
pattern: '**/*.vue',
pathPrefix: false,
prefix: '',
global: true,
})

// TODO: Add KToggle

logger.success('Globally registered all Kongponents')
},
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"module": "./dist/kongponents.es.js",
"files": [
"dist",
"src",
"bin"
],
"types": "dist/types/index.d.ts",
Expand Down

0 comments on commit 2722fe0

Please sign in to comment.