【问题标题】:Best practices for bower componentsBower 组件的最佳实践
【发布时间】:2015-07-09 13:32:47
【问题描述】:

所以我才刚刚开始使用 gulp、bower 和 polymer 等工具编写前端代码。

我通过 Bower 安装了聚合物和一些材料设计组件。

最佳实践是从 bower_component 文件夹中引用文件,例如:

<link rel="import" href="bower_components/paper-button/paper-button.html">

或者我应该使用 gulp 将需要的内容复制到另一个文件夹结构。

谢谢!

【问题讨论】:

    标签: gulp bower


    【解决方案1】:

    wiredep 很可能是您正在寻找的包。

    它将搜索 bower_components 文件夹并将所有依赖文件注入您的 index.html

    在 HTML 中的用法:

    <html>
    <head>
      <!-- bower:css -->
      <!-- endbower -->
    </head>
    <body>
      <!-- bower:js -->
      <!-- endbower -->
    </body>
    

    而在 gulp 中,您只需要:

    gulp.src('index.html')
      .pipe(wiredep({
        optional: 'configuration',
        goes: 'here'
      }))
      .pipe(gulp.dest('./dest'));
    

    【讨论】:

      【解决方案2】:

      创建.bowerrc

      应该看起来像:

      ex:.bowerrc
      
      {
       "directory:"folder/path"
      }
      
      do:bower install
      

      【讨论】:

        猜你喜欢
        • 2016-03-28
        • 1970-01-01
        • 2011-09-20
        • 2017-08-04
        • 2011-03-11
        • 2017-12-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多