【发布时间】:2015-11-04 11:46:37
【问题描述】:
我有带有字体的 sass 文件:
$icons-font-path: "~material-design-icons/iconfont/";
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(#{$icons-font-path}/MaterialIcons-Regular.woff2) format('woff2');
}
以及将字体下载到特定目录 (/home/user/project/example/src/static/fonts/) 的文件加载器:
{
test: /\.(woff|woff2|eot|ttf)$/,
loader: 'file',
query: {
name: path.join(STATIC_PATH, 'fonts', '/[name]-[hash].[ext]')
}
},
这对我来说没问题,但是在 url 中的 css 具有相同的路径,例如:
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(/home/user/project/example/src/static/fonts/MaterialIcons-Regular.woff2) format('woff2');
}
如何将woff2复制到特定目录并为url(prefix/MaterialIcons-Regular.woff2)设置特定前缀?
【问题讨论】:
标签: javascript css webpack