当前位置:  开发笔记 > 前端 > 正文

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

如何解决《如何在angularcli项目中包含node_modules中的资源》经验,为你挑选了2个好方法。

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

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

  "assets": [
    "../node_modules//assets/"
  ]

脚本工作正常,但是

 "scripts": [  
    "../node_modules//some.js",     
    "startup.js"
 ]

角度版本:2.4.1

Angular CLI:1.0.0-beta.24

有什么建议吗?



1> luvaas..:

这确实存在!

修复#3555

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

角度版本2-5:

"assets": [
  "assets",
  { "glob": "**/*", "input": "../node_modules//assets/", "output": "./assets/" }
]

角度版本> = 6:

"assets": [
  "src/favicon.ico",
  "src/assets",
  {
    "glob": "**/*",
    "input": "./node_modules///",
    "output": "./assets/"
  },


不幸的是,这对于角度6不再有效。有关角度6的配置,请参见下面的答案。
这适用于“ ng build”,但不适用于“ ng serve”。

2> t.animal..:

由于角度6,配置略有变化.要实现这一点,请更改assets相应构建器的属性angular.json(请注意,架构师中至少有两个相关的构建器,build并且test!)

"assets": [
  "src/favicon.ico",
  "src/assets",
  {
    "glob": "**/*",
    "input": "./node_modules//",
    "output": "./assets/"
  },

推荐阅读
mobiledu2402851173
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有