【问题标题】:How to use grunt-bower-install to update multiple html files如何使用 grunt-bower-install 更新多个 html 文件
【发布时间】:2014-03-31 12:00:45
【问题描述】:

我正在使用由 yeoman angular-generator 生成的 grunt 文件。有多个文件需要 bower-install 来更新,现在 bower-install 配置是这样的

// Automatically inject Bower components into the app
'bower-install': {
  app: {
    html: '<%= yeoman.app %>/index.html',
    ignorePath: '<%= yeoman.app %>/'
  }
},

我尝试使用

    html: ['<%= yeoman.app %>/index.html','<%= yeoman.app %>/manager.html']

在运行grunt bower-install时,出现以下错误

Running "bower-install:app" (bower-install) task
Warning: path must be a string Use --force to continue.

Aborted due to warnings.

bower-install 插件版本是

"grunt-bower-install": "~0.7.0",

我的问题是这个版本是否支持更新多个 html 文件?如果是,怎么做?

【问题讨论】:

    标签: gruntjs bower-install


    【解决方案1】:

    您可以定义多个目标来更新多个 html 文件,如下所示:

    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      },
      app2: {
        html: '<%= yeoman.app %>/manager.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    }
    

    【讨论】:

      【解决方案2】:

      看起来最新版本使用了更灵活的方式来定位文件以进行注入...

      https://github.com/stephenplusplus/grunt-bower-install

      target: {
          ...
          src: [
            'app/views/**/*.html',
          ...
      

      【讨论】:

        猜你喜欢
        • 2014-09-14
        • 2014-07-05
        • 2015-08-08
        • 1970-01-01
        • 2014-04-09
        • 1970-01-01
        • 2014-10-03
        • 1970-01-01
        • 2015-08-20
        相关资源
        最近更新 更多