问题
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