My Personal Junkyard

Web Development

Publish Vue component as NPM Package in 5 minutes…

anson

Publish Vue component as NPM Package in 5 minutes...

Expected Usage

In your Vue app


Steps

Folder strcture

Generate the following directory structure in your project folder.

package.json

./src/index.js

This file provides an install function for Vue to detect if this indeed a Vue application, then install the component automatically.

./build/rollup.config.js

Minimum setup for Rollup configuration.

./src/my-component.vue

A sample component for the sake of demonstration.

Serve

Install @vue/cli if you haven't done so.

Build

Publish

If you don't have a NPM package account, you will need to sign one up. Once you have signed up, you can use the npm adduser command to login from the terminal.

Tags:
Back to top