Grunt usemin适用于html和css,但不适用于js

时间:2015-10-08 19:58:03

标签: angularjs node.js gruntjs grunt-usemin angular-fullstack

我正在尝试将usemin与多个客户端html文件一起使用。我通过for循环添加每个客户端的usemin功能。

我使用了以下HTML和CSS方法:

initConfig.usemin[key+'-html'] = {
  options: {
      assetsDirs : [
        clients[key].dist,
        clients[key].dist+'/assets/images',
        clients['shared'].dist,
        clients['shared'].dist+'/assets/images'
      ],
      type:'html',
      patterns: {
        js: [
          [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
        ]
      }
  },
  files: {
      src: [
          clients[key].dist+'/{,*/}*.html'
      ]
  }
};
initConfig.usemin[key+'-css'] = {
  options: {
      assetsDirs : [
        clients[key].dist,
        clients[key].dist+'/assets/images',
        clients['shared'].dist,
        clients['shared'].dist+'/assets/images'
      ],
      type:'css',
      patterns: {
        js: [
          [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
        ]
      }
  },
  files: {
      src: [
          clients[key].dist+'/{,*/}*.css'
      ]
  }
};

不幸的是,我无法让这个JS工作:

initConfig.usemin[key+'-js'] = {
  options: {
      assetsDirs : [
        clients[key].dist,
        clients[key].dist+'/assets/images'
      ],
      type:'js',
      patterns: {
        js: [
          [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
        ]
      }
  },
  files: {
      src: [
          clients[key].dist+'/{,*/}*.js'
      ]
  }
};

我收到以下错误:

Warning: Unsupported pattern: js Use --force to continue.

有什么想法吗?

我已经测试过这里提到的解决方案适用于一个客户端,但我使用多个客户端和他们自己的index.html文件并得到上面提到的相同错误:

How to let grunt usemin update the JS to reference our revved images?

0 个答案:

没有答案