How to override Bootstrap variables in Vue workflow ( Vanilla Bootstrap )?

こ雲淡風輕ζ 提交于 2021-02-08 04:39:46

问题


The officially recommended way to customize / theme bootstrap is by overriding the bootstrap variables using sass. But how do I do this, or rather, how do I add this part of the process into the Vue webpack workflow ?

Googling led to try editing the vue.config.js file to add scss loader into webpack but I am unable to find the required file.

This is the directory structure

I have used vue-cli v3.4 to setup the project.

I am using vanilla bootstrap and not the bootstrap-vue components.


回答1:


Make a file called custom.scss. Go into the node_modules/bootstrap/scss directory and copy everything from _variables.scss. Paste these into your custom.scss.

In your style.scss import your custom.scss before you import bootstrap.scss.

Now in your main.js import @/assets/style.scss.

You will need to remove the !default flag from any variables you wish to override in your custom.scss for them to take effect, as well.



来源:https://stackoverflow.com/questions/54829710/how-to-override-bootstrap-variables-in-vue-workflow-vanilla-bootstrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!