javascript - Webpack load fonts -
i have code in react element:
require('../../style/fonts/somethingstrange.ttf')
in webpack.config:
{ test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, loader: 'file-loader?name=fonts/[name].[ext]' }
problem: no font on webpages...
doesn't webpack let me automatically require fonts? have program else load fonts?
you have require fonts inside css files, not inside js/jsx files. example:
@font-face { font-family: 'somethingstrange'; src: url('../../style/fonts/somethingstrange.ttf'); }
Comments
Post a Comment