this stackoverflow answer 对这个问题进行了相当全面的讨论,但我仍然花了一些时间来破解所有步骤。
首先,如果您使用的是 sass,请在顶部包含 font-awesome:
$fa-font-path: "../bower_components/font-awesome/fonts";
@import 'font-awesome/scss/font-awesome';
这个作品正在运行“grunt serve”,但是当我运行“grunt serve:dist”时图标不见了。
对于将 grunt 构建到 dist,在 Gruntfile.js 中的“复制”任务下添加以下内容:
{
expand: true,
cwd: '.',
src: 'bower_components/font-awesome/fonts/*',
dest: '<%= yeoman.dist %>'
}
您的整个“复制”任务可能看起来像这样(我的示例):
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'*.html',
'views/{,*/}*.html',
'images/{,*/}*.{webp}',
'fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: ['generated/*']
}, {
expand: true,
cwd: '.',
src: 'bower_components/font-awesome/fonts/*',
dest: '<%= yeoman.dist %>'
}, {
expand: true,
cwd: '.',
src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
dest: '<%= yeoman.dist %>'
}]
},
},
然后'grunt serve:dist' 工作并且图标显示正确。希望这可以节省别人的时间!