library_components/modules/module.ts
2024-07-08 13:24:09 +02:00

53 lines
1.0 KiB
TypeScript

// modules/my-module.ts
import {
defineNuxtModule,
createResolver,
addComponent,
addImports,
} from "@nuxt/kit";
export interface ModuleOptions {}
const components = [
{
name: "MlButton",
path: "../src/components/Ml/Button/MlButton.vue",
},
{
name: "MlPaginator",
path: "../src/components/Ml/Paginator/MlPaginator.vue",
},
{
name: "MlDropDown",
path: "../src/components/Ml/DropDown/MlDropDown.vue",
},
{
name: "MlDropDownItem",
path: "../src/components/Ml/DropDown/MlDropDownItem.vue",
},
];
export default defineNuxtModule<ModuleOptions>({
meta: {
name: "module",
configKey: "myModule",
},
defaults: {},
setup(_options, _nuxt) {
const resolver = createResolver(import.meta.url);
for (let item of components) {
addComponent({
name: item.name,
filePath: resolver.resolve(item.path),
});
}
addImports([
{
name: "useRipple",
from: resolver.resolve("../src/composables/useRipple.ts"),
},
]);
},
});