grunt-wiredep在具有不同依赖关系的多个文件上

Jai*_*dya 10 gruntjs bower grunt-wiredep wiredep

目前的项目结构有点像这样:

-index.html
|
-bower.json
|
+-bower_components
Run Code Online (Sandbox Code Playgroud)

建议的项目结构将在项目根目录中添加一些静态html文件.到目前为止,我一直在管理bower.json中的所有前端依赖项,并使用grunt-wiredep任务将其自动包含在index.html中.但是添加新文件后,每个文件都会有不同的依赖关系.

-index.html
|
-file-with-some-other-bower-dependency.html
|
-bower.json
|
+bower_components
Run Code Online (Sandbox Code Playgroud)

使用不同的bower依赖关系管理这些文件的有效方法是什么?

sab*_*sab 1

您可以执行两个不同的任务,每个任务都有自己的依赖项(bowerJson):

  grunt.initConfig({
wiredep: {
  app: {
    src: 'index.html',
    "bowerJson":{
      "dependencies": {
        "jquery":"=2.1.3",
          ...
      }
    }

  },
  app2: {
    src: 'file-with-some-other-bower-dependency.html',
    "bowerJson": {
      "dependencies": {
        "bootstrap": "~3.0.0",
        ...
      }
    }
  }}
Run Code Online (Sandbox Code Playgroud)