咕wired的wiredep不接线一些凉亭组件 [英] Grunt wiredep not wiring some bower components

查看:71
本文介绍了咕wired的wiredep不接线一些凉亭组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用yeoman webapp生成器生成模板以启动我的工作。此时,我的bower.json看起来像这样

I am using yeoman webapp generator to generate a template to kick start of my work. At this moment, my bower.json looks like this


  {
    "name": "sample-project",
    "private": true,
    "dependencies": {
      "bootstrap-sass": "~3.3.5",
      "modernizr": "~2.8.3",
      "fontawesome": "~4.3.0",
      "jquery.smooth-scroll": "~1.5.5",
      "animate.css": "~3.3.0",
      "jquery.appear": "*"
    },
    "overrides": {
      "bootstrap-sass": {
        "main": [
          "assets/stylesheets/_bootstrap.scss",
          "assets/fonts/bootstrap/*",
          "assets/javascripts/bootstrap.js"
        ]
      }
    },
    "devDependencies": {
      "chai": "~3.0.0",
      "mocha": "~2.2.5"
    }
  }

现在,在cmd提示符下,我正在运行咕unt声手表时键入此提示

Now, in cmd prompt I type this while grunt watch is running

bower install bootstrap-datepicker -S

然后我找到 bootstrap-datepicker: 〜1.4.0 插入到依赖项部分,然后

Then I found "bootstrap-datepicker": "~1.4.0" is inserted into the dependencies section, then

<script src="bower_components/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

将被自动连接到我的index.html中,变成这样

will be automatically wiredep into my index.html, it becomes this

  <!-- build:js(.) scripts/vendor.js -->
  <!-- bower:js -->
     .
     .
     <script src="bower_components/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
  <!-- endbower -->
  <!-- endbuild -->

然后我尝试在我的Web应用程序中安装另一个Bower组件

Then I try to install another bower component to my webapp

bower install country-region-selector -S

接下来发生的事情是我发现 country-region-selector:〜0.1.8 在bower.json的依赖项下,如bootstrap-datepicker,但是相应的

The next thing happens is I found "country-region-selector": "~0.1.8" is under dependencies section of bower.json like bootstrap-datepicker, however the corresponding

<script src="bower_components/country-region-selector/dist/crs.min.js"></script>

不会进入我的index.html。

doesn't get wiredep into my index.html.

所以我的问题是,为什么咕unt声的有线耳机不适用于某些凉亭部件? form.validation 也发生了同样的事情?有人可以对此问题有所了解吗?

So my question is why grunt wiredep doesn't work on some bower components? The same thing happens to form.validation Could anybody shed some light on this problem?

推荐答案

grunt-wiredep 的工作方式非常特定。依赖项应该在 bower.josn 中的 main 属性内的数组中列出,就像您在引导程序中提到的示例一样。

grunt-wiredep works in a very specific way. The dependencies should be listed in an array inside the main property in bower.josn like the example you mentioned from bootstrap.

您面临的问题可能是那些软件包没有 main 属性,或者它正在使用多个文件

The problem you are facing is probably those packages doesn't have a main property or it is using multiple files in a string not an array.

要解决此问题,您始终可以为包 main 属性定义一个替代。喜欢以下内容...

To fix that, you can always define an override for the packages main property likes the following ...

在您的grunt文件中:

In your grunt file:

wiredep: {
    ...
    overrides: {
      'package-name': {
        'main': [
          'link-to-css-file.css',
          'link-to-js-file.js'
        ]
      },
    },
},

这篇关于咕wired的wiredep不接线一些凉亭组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆