我正在尝试为我的网站添加font-awesome图标。
这是我的webpack配置:
module.exports = {
watch: true,
context: __dirname + '/src',
entry: './entry.js',
devTool: "source-map",
output: {
path: __dirname + "/dist",
publicPath: '/dist/',
contentBase: __dirname + '/dist/',
filename: '[name].js'
},
module: {
loaders: [
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},
{test: /\.(otf|gif|png|jpg|JPG)$/, loader: "url-loader"},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file"
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml"
}
]
}
};
在开发服务器中,它运行得很好,但是当我尝试打开dist/index.html时,它找不到字体。我是这样包含它的:
@import "~font-awesome/css/font-awesome.min.css";
我认为,在我的webpack.config文件中出现了错误。但其他字体按预期工作。
publicPath
更改为/elegant/dist/
或./dist/
。 - Bob Sponge