Add Bootstrap to existing Vuejs project



1) npm install bootstrap@4.0.0-beta popper.js jquery bootstrap-vue --save-dev


2) //declare at the beggining in vue.config

var webpack = require('webpack');


3) //Add inside module.exports in vue.config


configureWebpack: {

    plugins: [

      // ...

      new webpack.ProvidePlugin({

          $: 'jquery',

          jQuery: 'jquery',

          'window.jQuery': 'jquery',

          Popper: ['popper.js', 'default'],

          // In case you imported plugins individually, you must also require them here:

          Util: "exports-loader?Util!bootstrap/js/dist/util",

          Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",

          // ...

      })

      // ...

  ]

  }


4) //main.js

import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'

import 'bootstrap/dist/css/bootstrap.css'

import 'bootstrap-vue/dist/bootstrap-vue.css'

import 'jquery/src/jquery.js'

import 'bootstrap/dist/js/bootstrap.min.js'


// Make BootstrapVue available throughout your project

Vue.use(BootstrapVue)

// Optionally install the BootstrapVue icon components plugin

Vue.use(IconsPlugin)


5) App.vue

<template>


  <div class="hello">

    <b-button>Button</b-button> ...

--For my future reference

0 comentarios:

Publicar un comentario