问题
When I compile fontawesome.scss to a css file with sass 3.4.1
$fa-var-music: "\f001";
.#{$fa-css-prefix}-music:before { content: $fa-var-music; }
it is compiled to
.fa-music:before {
content: "";
}
As I'm mainly using Win1252 encoding in my project I'm wondering what's the way to preserve "\f001" in the css file. Why does SASS rewrite?
回答1:
Extract from Sass 3.4.0 changelog: Sass now follows the CSS Syntax Level 3 specification for determining a stylesheet’s encoding. In addition, it now only emits UTF-8 CSS rather than trying to match the source encoding.
Now no way for use old metod
Issue on SASS repo
For me, rollback to SASS 3.3.14 fix this
回答2:
If you are using Gulp to compile your CSS, you can install this gulp plugin and it will automatically fix the issue for you. No Sass code alterations necessary.
https://www.npmjs.com/package/gulp-sass-unicode
var sass = require('gulp-sass');
var sassUnicode = require('gulp-sass-unicode');
gulp.task('sass', function(){
gulp.src('style.scss')
.pipe(sass())
.pipe(sassUnicode()) // << This line is what does the magic
.pipe(gulp.dest( "css/" ));
});
来源:https://stackoverflow.com/questions/25488037/sass-compile-fontawesome-preserve-notation