【Webpack】@import ~
@import"~bootstrap/dist/css/bootstrap.min.css"
@import"~font-awesome/css/font-awesome.min.css"
前面加 ~
表示你后面的值为 alias
, 然后就会去 webpack``alias
配置中找相应的值, 然后拼接成最后的地址, 例如
resolve: {
alias: {
"bootstrap": "xxx/xxx2",
"font-awesome": "yyy/yyy2",
}
}
@import "~bootstrap/dist/css/bootstrap.min.css"
@import "~font-awesome/css/font-awesome.min.css"
等同于
@import "xxx/xxx2/bootstrap/dist/css/bootstrap.min.css"
@import "yyy/yyy2/font-awesome/css/font-awesome.min.css"