4

I'm using Laravel 5.6, Laravel Mix 2.0, and Bootstrap-Vue 2.0.0-rc.1.

Trying to find a way to configure Laravel Mix to include Bootstrap-Vue's CSS into my app.css file and prevent Bootstrap-Vue from including <style> tags into the page <head>.

I saw this note in the package docs but still not sure how to use this properly:

Note: requires webpack configuration to load css files (official guide)

2 Answers 2

2

Finally, found a solution - ExtractTextPlugin.

let mix = require('laravel-mix');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

mix.js('resources/assets/js/app.js', 'public/js')
  .sass('resources/assets/sass/app.scss', 'public/css');

mix.webpackConfig({
  module: {
    rules: [
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: 'css-loader'
        })
      }
    ]
  }
});

Reference: https://github.com/JeffreyWay/laravel-mix/issues/1589

Sign up to request clarification or add additional context in comments.

Comments

1

Install:

  1. npm i bootstrap-vue
  2. npm install --save-dev style-loader css-loader

Use:

edit resources/js/app.js to:

  1. import Vue from 'vue'

  2. import BootstrapVue from 'bootstrap-vue'

  3. Vue.use(BootstrapVue)

edit resources/sass/app.scss to:

  1. Import the styles:
    • import '~bootstrap/dist/css/bootstrap.css'
    • import '~bootstrap-vue/dist/bootstrap-vue.css'

Make sure the app.js and app.css are included in the blade(view) that is acting as the container for your vue. See: https://bootstrap-vue.js.org/docs/

5 Comments

I was asking about the CSS. Both, JS and CSS, are working fine for me. Just want to move CSS from <style> tags into my compiled CSS file.
@Roman Tolstoy, you just have to add: import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap-vue/dist/bootstrap-vue.css'
This doesn't help to get rid of <style> tags inserted into <head> by BootstrapVue.
@RomanTolstoy so you want to use <link rel="stylesheet" href="path/to/stylesheet"> instead of <style>/** shit tons of injected css **/</style>?
I am using the compiled app.css file already (the resulting file with all the CSS compiled by Laravel Mix). I just want all these inline styles from the Bootstrap-Vue components to be included in the app.css instead of bloating the page size.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.