Raja Rao
Raja Rao

Reputation: 5885

How to use a Vue plugin to Vuepress?

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.

Upvotes: 6

Views: 1743

Answers (2)

dkaramazov
dkaramazov

Reputation: 204

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({});
}

Upvotes: 7

TotomInc
TotomInc

Reputation: 662

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.

Upvotes: 1

Related Questions