How to include assets from node_modules in angular cli project

后端 未结 3 815
南笙
南笙 2020-12-05 09:15

How to include assets from external library into Angular CLI project

I am trying below but this does not work,

  \"assets\": [
    \"../node_modules/         


        
相关标签:
3条回答
  • 2020-12-05 09:51

    This does now exist!

    Fix #3555

    To use it, update your .angular-cli.json file like so...

    Angular version 2-5:

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

    Angular version >= 6:

    "assets": [
      "src/favicon.ico",
      "src/assets",
      {
        "glob": "**/*",
        "input": "./node_modules/<your-node-module>/<possibly-subfolders>/",
        "output": "./assets/"
      },
    
    0 讨论(0)
  • 2020-12-05 09:56

    Unfortunately, this doesn't exist yet :(. I'm desperately awaiting this feature also. Feel free to track this feature request here for Angular-Cli. Copying assets from node_modules

    Updated

    See @luvaas response as of Angular 6!

    0 讨论(0)
  • 2020-12-05 09:59

    Since angular 6 the config has changed slightly. To achieve this now, change the assets property of the respective builder in angular.json (beware, there are at least two relevant builders in the architects build and test!)

    "assets": [
      "src/favicon.ico",
      "src/assets",
      {
        "glob": "**/*",
        "input": "./node_modules/<your-node-module>/<possibly-subfolders>",
        "output": "./assets/<possibly-subfolders>"
      },
    
    0 讨论(0)
提交回复
热议问题