【发布时间】:2018-07-13 07:33:31
【问题描述】:
我有 4 个 SASS 文件 main.sass、_fonts.sass、_variables.sass、_home.sass。
main.sass
@import 'fonts'
@import 'variables'
@import 'home'
_fonts.sass
@font-face
font-family: "FontAwesome"
font-weight: normal
font-style: normal
src: url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.eot?v=4.3.0")
src: url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0") format("embedded-opentype"), url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0") format("woff2"), url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff?v=4.3.0") format("woff"), url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.ttf?v=4.3.0") format("truetype"), url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular") format("svg")
_variables.sass
$yellow: #fce001
_home.sass
.container
color: $yellow
text-align: right
.another-container
color: $yellow
text-align: center
&:after
content: '\f0b0'
font-family: FontAwesome
font-style: normal
font-weight: normal
text-decoration: inherit
position: absolute
right: 20px
display: inline-block
font-size: 1.1em
这是我的示例 HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>hello</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
<div class="container">
container
</div>
<div class="another-container">
another-container
</div>
</body>
</html>
我正在使用以下命令编译我的 SASS 文件:sass --watch main.sass:style.css
当我检查我的 google chrome 检查元素到 container 或 another-container 时,它指向 _variables.sass 而不是 _home.sass。 _variables.sass 只包含变量。我希望它指向_home.sass。
@更新
我设法查明导致错误的原因,在content: '\f0b0' 中的_home.sass 中,如果我删除它,源映射指向正确的行,为什么会导致错误?
【问题讨论】:
-
你是如何编译 sass 的?
-
@IsmailFarooq,查看我更新的问题
-
将你的文件 home.sass 重命名为 _home.sass 并再次编译
-
@IsmailFarooq,错误仍然存在,我再次更新了我的问题。
-
你使用
GEMSass吗?或者你正在使用Node-Sass?