library_components/modules/module.ts

53 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-07-08 09:15:33 +00:00
// modules/my-module.ts
2024-07-08 10:53:06 +00:00
import {
defineNuxtModule,
createResolver,
addComponent,
addImports,
} 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 11:24:09 +00:00
{
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",
},
2024-07-08 10:36:47 +00:00
];
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 10:53:06 +00:00
addImports([
{
name: "useRipple",
from: resolver.resolve("../src/composables/useRipple.ts"),
},
]);
2024-07-08 09:15:33 +00:00
},
});