library_components/modules/module.ts

29 lines
607 B
TypeScript
Raw Normal View History

2024-07-08 09:15:33 +00:00
// modules/my-module.ts
2024-07-08 10:36:47 +00:00
import { defineNuxtModule, createResolver, addComponent } from "@nuxt/kit";
2024-07-08 09:15:33 +00:00
export interface ModuleOptions {}
2024-07-08 10:36:47 +00:00
const components = [
{
name: "MlButton",
path: "../src/components/Ml/Button/MlButton.vue",
},
];
2024-07-08 09:15:33 +00:00
export default defineNuxtModule<ModuleOptions>({
meta: {
name: "module",
configKey: "myModule",
},
defaults: {},
setup(_options, _nuxt) {
const resolver = createResolver(import.meta.url);
2024-07-08 10:36:47 +00:00
for (let item of components) {
addComponent({
name: item.name,
filePath: resolver.resolve(item.path),
});
}
2024-07-08 09:15:33 +00:00
},
});