How to use a Vue plugin to Vuepress?

1.6k Views Asked by At

For example, I want to add https://github.com/Akryum/v-tooltip tooltip plugin to my Vuepress project. It asks us to do Vue.use, not sure how to do that because I get "Vue" is undefined.

2

There are 2 best solutions below

0
On

You can actually install Vue plugins by editing .vuepress/config.js and passing the plugins array which can be composed of plugins names or require statements.

For more information see this doc.

0
On

What you're trying to do is extend the instance of Vue.

Create an enhanceApp.js file. You will then have access to the instance of Vue that Vuepress is using and be able to extend it.

Here is a link to the doc on the enhanceApp.js file.

Here is an example of bringing in Vuetify.

// .vuepress/enhanceApp.js

import Vuetify from 'vuetify'

export default ({
    Vue,
    options,
    router,
    siteData
}) => {
    Vue.use(Vuetify)
    options.vuetify = new Vuetify({});
}