This is a part of my nuxt.config.js file:
head: {
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
// load bootsttrap.css from CDN
//{ type: 'text/css', rel: 'stylesheet', href: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' },
]
},
css: [
// this line include bootstrap.css in each html file on generate
'bootstrap/dist/css/bootstrap.css',
'assets/main.css'
],
In this case bootstrap.css included in each html file on nuxt generate. For resolve it I comment line 'bootstrap/dist/css/bootstrap.css' in css section and uncomment rel stylesheet line in link section.
After this bootstrap.css file loaded from CDN and not included in html files. So, I think it not is very well idea.
How copy bootstrap.css from 'node_modules/bootstrap/dist/...' to '~/assets' on build, and after this, load it from here?
I use this solution, works like a charm and is the best one in my opinion, fast and easy, follow these steps:
1 .Install bootstrap-vue
npm i bootstrap-vue
2.Create the file plugins/bootstrap-vue.js and in it type:
/* eslint-disable import/first */
import Vue from 'vue'
import BootstrapVue from 'bootstrap-vue'
Vue.use(BootstrapVue)
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
3.Add created plugin to nuxt.config.js ... plugins: [ '@/plugins/bootstrap-vue', ], ...
After these steps it should work and you can use bootstrap.