简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM