我正在使用 webpack 来编译我的 sass 文件。
我有一个font-face
看起来像这样:
@font-face
font-family: "Alef"
src: url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.eot")
src: url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.eot?#iefix") format("embedded-opentype"), url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.woff") format("woff"), url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.ttf") format("truetype"), url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.svg#alefbold") format("svg")
font-weight: bold
font-style: normal
这就是我的 webpack 配置文件中的加载器的样子
{
test: /\.html$/,
loader: 'html'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?[a-z0-9=&.]+)?$/,
loader: 'file?name=assets/[name].[hash].[ext]'
},
{
test: /\.sass$/,
exclude: /node_modules/,
loader: 'raw-loader!sass-loader'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw'
}
但是,我在 ttf 和 woff 上收到 404,因此此字体仅出现在 chrome 中(不会出现在 Firefox 和 Edge 中)
thanks!