Remember the ModuleContainer instance and the this.addPlugin helper method that you can access via the this keyword that we covered in the Writing a basic module section? In this example, we will create a module that provides a plugin by using this helper, and that plugin is bootstrap-vue, which will be registered in the Vue instance. Let's create this module snippet with the following steps:
- Install Bootstrap and BootstrapVue:
$ npm i bootstrap-vue
$ npm i bootstrap
- Create a plugin file to import vue and bootstrap-vue and then register bootstrap-vue using the use method:
// modules/bootstrap/plugin.js
import Vue from 'vue'
import BootstrapVue from 'bootstrap-vue/dist/bootstrap-vue.esm'
Vue.use(BootstrapVue)
- Create a module file to add the plugin file we just created using the addPlugin method:
// modules/bootstrap/module.js
import path from 'path'
export default function (moduleOptions) {
this.addPlugin...