How to use Bootstrap mixins in VueJS components

后端 未结 1 1665
小鲜肉
小鲜肉 2021-01-22 14:17

I\'m using vue-cli + bootstrap-vue. I can\'t figure out why and how bootstrap mixins not working at all despite I imported Bootstrap like this (in my main.js)

 i         


        
1条回答
  •  囚心锁ツ
    2021-01-22 14:55

    I figure it out. In case youre using vue-cli:

    Create file vue.config.js with content:

    const path = require("path");
    const loader = {
        loader: 'sass-resources-loader',
        options: {
          resources: path.resolve(__dirname, './src/assets/scss/global.scss')
        }
    }
    
    module.exports = {
        configureWebpack: {
            module: {
                rules: [
                {
                    test: /\.scss$/,
                    use: [
                    loader,
                    'sass-loader'
                    ]
                }
                ]
            }
        }
    };
    

    Don't forget to install sass-resources-loader:

    yarn add sass-resources-loader -D
    

    And restart dev server. So from now you can define/import variables, mixins and other stuff inside that global.scss and these variables/mixins will be available inside every component without import.

    0 讨论(0)
提交回复
热议问题