From ca17da363db9255b240df21b269b9c557b97d4ac Mon Sep 17 00:00:00 2001 From: Arina Yakovenko Date: Tue, 9 Jul 2024 11:09:16 +0200 Subject: [PATCH] add some files --- index.js | 15 ++-------- modules/module.ts | 75 +++++++++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 55 deletions(-) diff --git a/index.js b/index.js index 9c9fc67..31bb0dd 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,3 @@ -import { defineNuxtModule } from "@nuxt/kit"; +import MyModule from './modules/module'; -import { join } from "pathe"; - -export default defineNuxtModule({ - hooks: { - "components:dirs"(dirs) { - dirs.push({ - path: join(__dirname, "components/Ml/Button"), - prefix: 'Ml' - }); - }, - }, -}); +export default MyModule; \ No newline at end of file diff --git a/modules/module.ts b/modules/module.ts index 8a4d67e..7d143e8 100644 --- a/modules/module.ts +++ b/modules/module.ts @@ -5,94 +5,85 @@ import { addImports, } from "@nuxt/kit"; -import { join } from 'pathe'; - export interface ModuleOptions {} const components = [ { name: "MlButton", - path: "./components/Ml/Button/MlButton.vue", + path: "../components/Ml/Button/MlButton.vue", }, { name: "MlPaginator", - path: "./components/Ml/Paginator/MlPaginator.vue", + path: "../components/Ml/Paginator/MlPaginator.vue", }, { name: "MlDropDown", - path: "./components/Ml/DropDown/MlDropDown.vue", + path: "../components/Ml/DropDown/MlDropDown.vue", }, { name: "MlDropDownItem", - path: "./components/Ml/DropDown/MlDropDownItem.vue", + path: "../components/Ml/DropDown/MlDropDownItem.vue", }, { name: "MlSlider", - path: "./components/Ml/Slider/MlSlider.vue", + path: "../components/Ml/Slider/MlSlider.vue", }, { name: "MlSliderPoint", - path: "./components/Ml/SliderPoint/MlSliderPoint.vue", + path: "../components/Ml/SliderPoint/MlSliderPoint.vue", }, { name: "MlTabberBase", - path: "./components/Ml/Tabber/MlTabberBase.vue", + path: "../components/Ml/Tabber/MlTabberBase.vue", }, { name: "MyComponent", - path: "./components/MyComponent", + path: "../components/MyComponent", }, ]; const composables = [ { name: "useRipple", - path: "./composables/useRipple.ts", + path: "../composables/useRipple.ts", }, { name: "useMergeClasses", - path: "./composables/useMergeClasses.ts", + path: "../composables/useMergeClasses.ts", }, { name: "useBounce", - path: "./composables/useBounce.ts", + path: "../composables/useBounce.ts", }, { name: "useTailwindConf", - path: "./composables/useTailwindConf.ts", + path: "../composables/useTailwindConf.ts", }, ]; export default defineNuxtModule({ - // meta: { - // name: "module", - // configKey: "myModule", - // }, - // defaults: {}, - // setup(_options, _nuxt) { - // const resolver = createResolver(import.meta.url); + 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), - // }, - // ]); - // } - // }, - hooks: { - "components:dirs"(dirs) { - dirs.push({ - path: join(__dirname, "components"), + 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), + }, + ]); + } }, });