with others all over the world! Some NPM Vue libraries we've used: vuetify vuex vue-i18n vue-clipboard2 vue-meta vue-qr ... and more 2 Publishing Vue components to NPM - By Jeremy Hall
We can use Vue CLI to export a component as a library. 1. Create a new vue project 2. Setup package.json metadata correctly 3. Documentation 4. Create an NPM account 5. Build your library using Vue CLI 6. Publish to NPM 3 Publishing Vue components to NPM - By Jeremy Hall
Install Vue CLI Create a project Create a project https://cli.vuejs.org/guide/installation.html yarn global add @vue/cli-service-global vue create my-component-project 5 Publishing Vue components to NPM - By Jeremy Hall
will give you a basic package.json le. But you will want to make sure that these elds are lled out correctly so that people can easily nd, understand, and use your component 6 . 1 Publishing Vue components to NPM - By Jeremy Hall
our component works. Otherwise noone will use our component Create a readme.md le Use Codesandbox to show how to use your component with a working demo 7 . 1 Publishing Vue components to NPM - By Jeremy Hall
of your project: Github will display this le for you on your repository's page NPM will also show this le when people view your package The le is created using the Markdown language. A special language for adding features to text like titles, sections, lists, and code blocks. See readme.md https://guides.github.com/features/mastering- markdown/ 7 . 2 Publishing Vue components to NPM - By Jeremy Hall
simple. Also easy for people to fork, edit, and test their own versions of your code: @nagoos/google-maps- autocomplete-vuetify Example Made by wallslide Files public favicon.ico index.html src App.vue main.js package json @nagoos/google-maps-autocomplete-vuet… Like Open in Editor App.vue package.json main.js index.html https://r2o5h.codesandbox.io/ Console 0 Problems 0 1 2 3 4 5 6 7 8 9 10 11 12 <template> <v-app> <v-content fluid fill-height> <v-layout align-center justify-center> <v-flex xs11> <v-layout column> <v-card> <v-layout column> <GoogleMapsAutocomplete v-model="address" :restrict-to-countries="['jp']" @initialized="mapsLoaded = true 7 . 3 Publishing Vue components to NPM - By Jeremy Hall
to the build- les in package.json les: We must include all les we want to include in npm here: dist/: The les that we built with Vue CLI src/: Lets bundlers use the .vue component directly unpgk: For embedding directly via CDN main: Standard way of using from NPM 9 . 7 Publishing Vue components to NPM - By Jeremy Hall
publish command, we need to increase the version eld in the package.json le, otherwise an error will be thrown. 10 . 2 Publishing Vue components to NPM - By Jeremy Hall