'How to run Vue 3/Vite app in library mode for test/demo purposes?

I am trying to create Vue 3 components library as a npm package using Vite.js. I have configured Vite accordingly to the docs. It works, but I need to test my library somehow.

Before I created libraries with vue-sfc-rollup and it has special script and folder for that purpose.

package.json (in vue-sfc-rollup):

"scripts": {
    "serve": "vue-cli-service serve dev/serve.ts"
....

And in that folder:

dev/
    serve.ts
    serve.vue

serve.ts:

import { createApp } from 'vue';
import Dev from './serve.vue';

const app = createApp(Dev);
app.mount('#app');

Which is creates a small SPA for testing/demo.

I am trying to achieve something similar to this with Vite. Any ideas?

UPD:

So, the question probably is how to specify certain main.js file while running Vite?



Solution 1:[1]

Take a look at this guide. You will not need vue-sfc-rollup anymore while you are using Vite. Vite uses rollup behind the scence.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Naing