library_components/modules/module.ts

41 lines
765 B
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 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
},
});