programing

angular cli 프로젝트에 node_modules의 자산을 포함하는 방법

lastmoon 2023. 8. 25. 23:54
반응형

angular cli 프로젝트에 node_modules의 자산을 포함하는 방법

Angular CLI 프로젝트에 외부 라이브러리의 자산을 포함하는 방법

아래에서 시도하고 있지만 작동하지 않습니다.

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

스크립트는 잘 작동하지만,

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

Angular 버전 : 2.4.1

Angular CLI : 1.0.0-베타.24

제안할 것이 있습니까?

이제 존재합니다!

수정 번호 3555

사용하려면 .angular-cli.json 파일을 다음과 같이 업데이트하십시오.

각도 버전 2-5:

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

각도 버전 >= 6:

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

각도 6 이후 구성이 약간 변경되었습니다.지금 이 작업을 수행하려면 다음을 변경합니다.assets에서의 각 건설업자의 재산.angular.json(따라서, 건축가에는 적어도의 관련 건설업자가 있습니다.build그리고.test!)

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

안타깝게도 이것은 아직 존재하지 않습니다 :(저도 이 특집을 간절히 기다리고 있습니다.Angular-Cli의 경우 여기에서 이 기능 요청을 자유롭게 추적할 수 있습니다.node_modules에서 자산을 복사하는 중

업데이트됨

Angular 6의 @luvaas 반응을 참조하십시오.

저는 이곳에 처음 왔는데, 제 경우 현재 응용 프로그램의 npm 패키지와 패키지 자체의 이미지를 통해 다른 응용 프로그램 UI를 호출해야 하는 것과 같은 npm 패키지 문제가 있습니다.

이 경우에 필요한 2가지 변경 사항:

  • 위의 각도 6, 각 ng-package json에서 다음을 추가합니다.assets:['./assets']하위 응용 프로그램에서 빌드의 dist 폴더에 자산/이미지 폴더를 만듭니다.

  • angular.json에서 (설계자와 테스트 모두에서) 상위 응용 프로그램에 다음을 추가합니다.

assets: [
   {
      "glob": "**/*",
      "input":"node_modules/"path of assets folder"/images"
   },
   "output":"./assets/images/"
]

언급URL : https://stackoverflow.com/questions/41555624/how-to-include-assets-from-node-modules-in-angular-cli-project

반응형