Browse Source

打包后的css引入字体文件路径修改

master
zq 1 week ago
parent
commit
d85c9b8d57
  1. 5
      build/webpack.config.js
  2. 2
      packages/styles/index.css

5
build/webpack.config.js

@ -46,9 +46,10 @@ module.exports = {
use: [{ use: [{
loader: 'url-loader', loader: 'url-loader',
options: { options: {
limit: 4096, // 4KB 以下转为 base64 limit: 4096,
name: 'fonts/[name].[hash:8].[ext]', name: 'fonts/[name].[hash:8].[ext]',
esModule: false // 避免 __webpack_require__.n 问题 esModule: false,
publicPath: '../', // 关键:修正 CSS 中的引用路径
} }
}] }]
}, },

2
packages/styles/index.css

@ -138,8 +138,6 @@
@font-face { @font-face {
font-family: element-icons; font-family: element-icons;
/* src: url('~element-ui/lib/theme-chalk/fonts/element-icons.woff') format('woff'),
url('~element-ui/lib/theme-chalk/fonts/element-icons.ttf') format('truetype'); */
src: url("./fonts/element-icons.woff") format("woff"), url("./fonts/element-icons.ttf") format("truetype"); src: url("./fonts/element-icons.woff") format("woff"), url("./fonts/element-icons.ttf") format("truetype");
font-weight: 400; font-weight: 400;
font-display: "auto"; font-display: "auto";

Loading…
Cancel
Save