Andrew Rusinas
Andrew Rusinas

Reputation: 1064

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?

Upvotes: 0

Views: 3519

Answers (1)

Naing
Naing

Reputation: 91

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.

Upvotes: 1

Related Questions