![9bcd59c49875494759ad841721b9b914.png](https://i-blog.csdnimg.cn/blog_migrate/0284ea34799e8bcb4a1261267f22fd9f.jpeg)
问题描述:
npm run dev字体图标正常显示,但是,,,,
npm run build后字体图标消失,见下图:
![cf651d3b5e9bccc525c56777109639fc.png](https://i-blog.csdnimg.cn/blog_migrate/314ee13b7a715f0e98ef885db6ec49e4.png)
解决方法:
webpack module配置:(build目录下webpack.base.conf.js)
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /.(woff2?|eot|ttf|otf)(?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
webpack utils.js 修改:(build目录下utils.js)
添加 publicPath: '../../'
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader',
publicPath: '../../'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
![07885c387501579b34d8acf55ef766df.png](https://i-blog.csdnimg.cn/blog_migrate/d0c8b5d33ea6ffedf8f9a855c45623d7.png)
完美Ending~