如何在angular cli项目中包含node_modules中的资源

时间:2017-01-09 19:39:16

标签: angular angular-cli

如何将外部库中的资产包含到Angular CLI项目中

我正在尝试下面,但这不起作用,

  "assets": [
    "../node_modules/<external library>/assets/"
  ]

脚本工作正常,

 "scripts": [  
    "../node_modules/<external library>/some.js",     
    "startup.js"
 ]

Angular Version:2.4.1

Angular CLI:1.0.0-beta.24

有什么建议吗?

3 个答案:

答案 0 :(得分:52)

现在确实存在!

Fix #3555

要使用它,请更新.angular-cli.json文件,如此...

Angular版本2-5:

"assets": [
  "assets",
  { "glob": "**/*", "input": "../node_modules/<external library>/assets/", "output": "./assets/" }
]

Angular版本&gt; = 6:

"assets": [
  "src/favicon.ico",
  "src/assets",
  {
    "glob": "**/*",
    "input": "./node_modules/<your-node-module>/<possibly-subfolders>/",
    "output": "./assets/"
  },

答案 1 :(得分:24)

自角度6起,配置略有变化。为此,请在assets中更改相应构建器的angular.json属性(请注意,建筑师build和{中至少有两个相关构建器{1}}!)

test

答案 2 :(得分:1)

不幸的是,这还不存在:(。我也在拼命等待这个功能。请在此处为Angular-Cli跟踪此功能请求。Copying assets from node_modules

相关问题