在具有不同依赖项的多个文件上使用grunt-wiredep

10

当前的项目结构大致是这样的:

-index.html
|
-bower.json
|
+-bower_components

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

-index.html
|
-file-with-some-other-bower-dependency.html
|
-bower.json
|
+bower_components

如何有效地管理具有不同Bower依赖项的这些文件?


1
grunt-wiredep会添加main属性中列出的文件的引用。它会扫描你提到的文件并自动添加这些依赖项。我认为你想要实现的不可能。 - Ahmad Alfy
这个项目是用AngularJS开发的吗? - Literally Illiterate
1个回答

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",
        ...
      }
    }
  }}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接