library_components/modules/module.ts
2024-07-08 13:59:47 +02:00

86 lines
1.7 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",
},
{
name: "MlDropDownItem",
path: "../src/components/Ml/DropDown/MlDropDownItem.vue",
},
{
name: "MlSlider",
path: "../src/components/Ml/Slider/MlSlider.vue",
},
{
name: "MlSliderPoint",
path: "../src/components/Ml/SliderPoint/MlSliderPoint.vue",
},
];
const composables = [
{
name: "useRipple",
path: "../src/composables/useRipple.ts",
},
{
name: "useMergeClasses",
path: "../src/composables/useMergeClasses.ts",
},
{
name: "useBounce",
path: "../src/composables/useBounce.ts",
},
{
name: "useTailwindConf",
path: "../src/composables/useTailwindConf.ts",
},
];
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),
});
}
for (let item of composables) {
addImports([
{
name: item.name,
from: resolver.resolve(item.path),
},
]);
}
},
});