0

我想将 highstock(highcharts 中的 highstock.js)集成到我的 jHipster 项目中。因此,我在 bower.json 中添加了以下内容:

"dependencies": {
  "highcharts" : "4.2.6",
  "highcharts-ng": "0.0.12"
},
"overrides": {
  "highcharts-ng": {
    "dependencies": {
        "angular": "1.5.8",
        "highcharts": "4.2.6"
    }
  }
}

当我使用此配置构建项目时,gulp 会在 index.html 文件中导入 javascript 依赖项,如下所示:

<script src="bower_components/highcharts/highcharts.js"></script>
<script src="bower_components/highcharts/highcharts-more.js"></script>
<script src="bower_components/highcharts/modules/exporting.js"></script>
<script src="bower_components/highcharts-ng/dist/highcharts-ng.js"></script>

但我实际上需要的只是 highstock.js: Highcharts 项目概述

我如何控制,这里导入了什么?

4

1 回答 1

1

解决方案在于 jHipster 使用的 gulp 插件“main-bower-files”,并在此处记录。

gulp 构建脚本根据 highcharts/bower.json 文件决定它导入的内容。在 highcharts 的情况下,指定以下内容:

{
  "name": "highcharts",
  "version": "v4.2.6",
  "main": [
    "highcharts.js",
    "highcharts-more.js",
    "modules/exporting.js"
  ]
}

如果你想覆盖它,你可以在你的项目 bower.json 中的“overrieds”部分中这样做,并指定它应该导入的 javascript:

"dependencies": {
  "highcharts" : "4.2.6",
  "highcharts-ng": "0.0.12"
},
"overrides": {
  "highcharts": {
    "main": "highstock.js"
  },
  "highcharts-ng": {
    "dependencies": {
      "angular": "1.5.8",
      "highcharts": "4.2.6"
    }
  }
}
于 2016-09-14T08:40:58.590 回答