This is a simple scaffold for a Vue 3 library. It uses Vite for building. You can use this as a starting point for your own library.
yarn yarn dev
- Change the name in 
package.json - Change the name in 
vite.config.js - Change the name in 
src/lib.ts - Change the import in 
src/main.tsto match the name insrc/lib.ts, used for demo purpose. (src/Demo.vue) - Have fun!
 
Currently Vue 3 lib mode does not support CSS injection, so the built library will separate the CSS file.
This will build the library and place it in the dist folder. You can then publish this folder to npm.
yarn build
Then publish the dist folder to npm.
yarn add <your-library-name>
// main.js // Import library styles import 'your-library-name/dist/style.css';
// Global import - Contains all components // main.js import YourLibraryName from 'your-library-name'; createApp(App).use(YourLibraryName).mount('#app'); // OR Individual component import // Component.vue import { YourComponentName } from 'your-library-name';
Currently I'm not applying any testing. All contributions are welcome.