导入图标字体文件出错时

时间:2018-07-20 03:39:29

标签: css webpack vue.js stylus

在我的项目中,我想使用图标字体。 这是icon.styl的一些内容:

@font-face {
 font-family: 'sell-icon';
 src:  url('../fonts/sell-icon.eot?o23a15');
 src:  url('../fonts/sell-icon.eot?o23a15#iefix') format('embedded-opentype'),
      url('../fonts/sell-icon.ttf?o23a15') format('truetype'),
      url('../fonts/sell-icon.woff?o23a15') format('woff'),
      url('../fonts/sell-icon.svg?o23a15#sell-icon') format('svg');
      font-weight: normal;
      font-style: normal;
 }

但是很不幸,编译时出现了4个错误:

 ERROR  Failed to compile with 4 errors                                                        
 11:22:32

 These relative modules were not found:

* ../fonts/sell-icon.eot?o23a15 in ./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-12835cef","scoped":false,"hasInlineConfig":false}!./node_modules/stylus-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/header/header.vue
* ../fonts/sell-icon.svg?o23a15 in ./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-12835cef","scoped":false,"hasInlineConfig":false}!./node_modules/stylus-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/header/header.vue
* ../fonts/sell-icon.ttf?o23a15 in ./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-12835cef","scoped":false,"hasInlineConfig":false}!./node_modules/stylus-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/header/header.vue
* ../fonts/sell-icon.woff?o23a15 in ./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-12835cef","scoped":false,"hasInlineConfig":false}!./node_modules/stylus-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/header/header.vue  

我已经安装了stylus-loader和css-loader:

npm install stylus stylus-loader --save-dev
npm install stylus css-loader --save-dev

并且字体和手写笔在同一目录中。 sell-icon。*文件位于fonts目录中。 icon.styl在手写笔目录中。

谁可以帮助我?

0 个答案:

没有答案