业务背景
- 使用
bootstrap
开发网站
- 开发中大量用到了
bootstrap
的scss
源码
src下的源代码
app.vue
<style lang="scss">
@import "@/assets/scss/_custom.scss";
.section {
@extend .d-flex;
margin: 0 auto;
}
body {
font-family: '微软雅黑';
}
assets/scss/_custom.scss
@import "~bootstrap/scss/_functions";
...
@import "~bootstrap/scss/_print";
$yellow: #f67524;
生产环境build后的css代码
app.css
//
// ... 所有的bootstrap代码也都在这儿了 ...
// 9000行左右
//
.d-flex, .section {
display: -webkit-box !important;
display: -ms-flexbox !important;
display: flex !important
}
body {
font-family: "\5FAE\8F6F\96C5\9ED1"
}
遇到的问题
- 我本意是想,打包的时候,只编译我自定义的css内容
- bootstrap我单独用
link url cdn
引用
- 但是webpack却把整个
bootstrap
也给我打包到每个css
文件里面去了
我的尝试
- 看文档说是在
scss
文件前面加上_
就不会打包了
- 实际上并不管用