【发布时间】:2018-12-07 12:49:13
【问题描述】:
我现在正在努力使用 webpack 来管理我的资产。 我已经用 yarn 安装了 font-awesome,并在我的网页中导入了 .css 文件。 我的问题是,即使我的 html 识别出 font-awesome.css 中的类,我尝试使用的图标仍显示为填充有四个数字(标识图标)的方格
我的 webpack 代码是:
// webpack.config.js
var Encore = require('@symfony/webpack-encore');
const HandlebarsPrecompiler = require('webpack-handlebars-precompiler');
Encore
// the project directory where all compiled assets will be stored
.setOutputPath('web/build/')
// .addEntry('fs', 'empty')
// the public path used by the web server to access the previous directory
.setPublicPath('/build')
.addEntry('fonts/glyphicons-halflings-regular.ttf', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf')
.addEntry('fonts/glyphicons-halflings-regular.eot', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.eot')
.addEntry('fonts/glyphicons-halflings-regular.svg', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.svg')
.addEntry('fonts/glyphicons-halflings-regular.woff', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff')
.addEntry('fonts/glyphicons-halflings-regular.woff2', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2')
.addEntry('fonts/font-awesome', './node_modules/components-font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
.addEntry('fonts/fontawesome-webfont.svg', './node_modules/font-awesome/fonts/fontawesome-webfont.svg')
.addEntry('fonts/fontawesome-webfont.ttf', './node_modules/font-awesome/fonts/fontawesome-webfont.ttf')
.addEntry('fonts/fontawesome-webfont.woff', './node_modules/font-awesome/fonts/fontawesome-webfont.woff')
.addEntry('fonts/fontawesome-webfont.woff2', './node_modules/font-awesome/fonts/fontawesome-webfont.woff2')
.addEntry('css/bootstrap', './node_modules/bootstrap/dist/css/bootstrap.css')
.addEntry('css/bootstrap-theme', './node_modules/bootstrap/dist/css/bootstrap-theme.css')
.addEntry('css/bootstrap-datepicker', './node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.css')
.addEntry('css/app', './src/SgbBundle/Resources/public/css/app.css')
// export the final configuration
module.exports = Encore.getWebpackConfig();
问题是,在检查器中,当我看到某些 html 内容中使用的规则时,例如
<i class="fa fa-graduation-cap fa-4x" aria-hidden="true" id="icon"></i>
识别'fa' 类、'fa-4x' 类但不识别'fa-graduation-cap' 类。并且该图标显示为一个空方块。
谢谢。
【问题讨论】:
-
你试过“fas fa-graduation-cap fa-4x”,多加一个's'
-
你用在线链接版本试过吗?
-
是的,网络版不行。
-
什么版本,V4 还是 V5?
标签: css webpack font-awesome yarnpkg symfony-3.3