简体   繁体   English

Grunt wiredep没有注入字体 - 真棒

[英]Grunt wiredep not injecting font-awesome

I'm currently working on a project that had already been started using yeoman . 我目前正在开发一个已经开始使用yeoman

For some reason, when I run grunt-wiredep all dependencies are correclty injected in my index.html except for font-awesome . 出于某种原因,当我运行grunt-wiredep ,除了font-awesome之外,我的index.html所有依赖grunt-wiredep都是相关的。

Here's my bower.json file: 这是我的bower.json文件:

{
  "name": "watermelon",
  "version": "0.0.0",
  "dependencies": {
    "angular": "^1.3.0",
    "angular-animate": "^1.3.0",
    "angular-bootstrap": "~0.13.3",
    "angular-cookies": "^1.3.0",
    "angular-google-maps-native": "~2.0.0",
    "angular-mocks": "~1.3.0",
    "angular-resource": "^1.3.0",
    "angular-route": "^1.3.0",
    "angular-sanitize": "^1.3.0",
    "angular-scenario": "~1.3.0",
    "angular-touch": "^1.3.0",
    "angular-ui-router": "~0.2.15",
    "bootstrap": "^3.2.0",
    "bootstrap-switch": "~3.3.2",
    "eonasdan-bootstrap-datetimepicker": "~4.15.35",
    "es5-shim": "^4.0.0",
    "font-awesome": "~4.4.0",
    "json3": "^3.3.0",
    "moment": "~2.10.6",
    "ng-tags-input": "3.0.0",
    "requirejs": "latest",
    "requirejs-domready": "latest",
    "stacktrace-js": "~0.6.4",
    "underscore": "~1.8.3"
  },
  "appPath": "."
}

And a link to Gruntfile.js : http://pastebin.com/xxZwAYRW 以及Gruntfile.js的链接: httpGruntfile.js

When I run grunt-wiredep only these css dependencies get injected: 当我运行grunt-wiredep只会注入这些css依赖项:

<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css" />
<link rel="stylesheet" href="bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css" />
<link rel="stylesheet" href="bower_components/ng-tags-input/ng-tags-input.min.css" />
<!-- endbower -->

This problem broke with the latest(4.4.0) commit to FontAwesome . 这个问题打破了FontAwesome最新(4.4.0)提交

The fix is pretty straight forward. 修复非常简单。 You need to set an override (or maybe use less, but I am not going to cover that). 您需要设置覆盖(或者可以使用更少,但我不打算覆盖它)。

{
  "name": "myProject",
  "version": "0.0.0",
  "dependencies": {
    "font-awesome": ">=4.4.0",
  },  
  "overrides":{
    "font-awesome": {
    "main": [
        "css/font-awesome.css"
    ]
    }
  }
}

OR (because fontawesome/font-awesome has both names registered) 或者 (因为fontawesome / font-awesome都注册了这两个名字)

{
  "name": "myProject",
  "version": "0.0.0",
  "dependencies": {
    "fontawesome": ">=4.4.0",
  },  
  "overrides":{
    "fontawesome": {
    "main": [
        "css/font-awesome.css"
    ]
    }
  }
}

You can do this by override bower package try this code i have edited your bower.json look for the change in bottom of this code.. hope it works 您可以通过覆盖bower包执行此操作尝试此代码我已编辑您的bower.json查找此代码底部的更改..希望它的工作原理

{
  "name": "watermelon",
  "version": "0.0.0",
  "dependencies": {
    "angular": "^1.3.0",
    "angular-animate": "^1.3.0",
    "angular-bootstrap": "~0.13.3",
    "angular-cookies": "^1.3.0",
    "angular-google-maps-native": "~2.0.0",
    "angular-mocks": "~1.3.0",
    "angular-resource": "^1.3.0",
    "angular-route": "^1.3.0",
    "angular-sanitize": "^1.3.0",
    "angular-scenario": "~1.3.0",
    "angular-touch": "^1.3.0",
    "angular-ui-router": "~0.2.15",
    "bootstrap": "^3.2.0",
    "bootstrap-switch": "~3.3.2",
    "eonasdan-bootstrap-datetimepicker": "~4.15.35",
    "es5-shim": "^4.0.0",
    "font-awesome": "~4.4.0",
    "json3": "^3.3.0",
    "moment": "~2.10.6",
    "ng-tags-input": "3.0.0",
    "requirejs": "latest",
    "requirejs-domready": "latest",
    "stacktrace-js": "~0.6.4",
    "underscore": "~1.8.3"
  },  

"overrides":{
    "font-awesome": {
    "main": [
        "css/font-awesome.min.css"
    ]
    }
 }

} }

bower install components-font-awesome --save

should fix it. 应该解决它。
It is mentioned on their Github page under Package Managers here 它是根据包管理器相应Github页面上提到这里

Seems bower component "font-awesome" has some issues. 似乎凉亭组件“font-awesome”有一些问题。 You can try using instead "components-font-awesome" in your bower.json, it will solve the issue of not correctly injecting the css file. 您可以尝试在bower.json中使用“components-font-awesome”,它将解决不正确注入css文件的问题。 you can take a look in it's Github repo here: https://github.com/components/font-awesome 你可以在这里查看它的Github回购: https//github.com/components/font-awesome

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM