TheFlyer1983
TheFlyer1983
NNuxt
Created by TheFlyer1983 on 6/12/2024 in #❓・help
Nuxt Devtools
No description
1 replies
NNuxt
Created by TheFlyer1983 on 4/5/2023 in #❓・help
Vue 3 Component Library in Nuxt 3
Hi, I'm trying to create a Vue 3 component library with Vite and typescript. I'm wondering if I am creating the plugin correctly because when I try and import the components I get the error Module '"sample-library"' has no exported member 'UiButton'. Did you mean to use 'import UiButton from "sample-library"' instead? Below is my index.ts file that is supposed to export my components:
import { App, Plugin } from 'vue';
import 'tailwindcss/tailwind.css';
import './index.css';

import UiButton from './components/UiButton.vue';

const SampleLibrary = {
install: (Vue: App) => {
Vue.component('UiButton', UiButton);
},
} as Plugin;

export default SampleLibrary;
import { App, Plugin } from 'vue';
import 'tailwindcss/tailwind.css';
import './index.css';

import UiButton from './components/UiButton.vue';

const SampleLibrary = {
install: (Vue: App) => {
Vue.component('UiButton', UiButton);
},
} as Plugin;

export default SampleLibrary;
I then import this into a plugin's file in my Nuxt app like this:
import SampleLibrary from 'sample-library';

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(SampleLibrary);
});
import SampleLibrary from 'sample-library';

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(SampleLibrary);
});
I would like to components to be registered globally and auto imported like normal components. I must be doing something wrong. Is anyone able to help with this?
5 replies