How to include assets from node_modules in angular cli project

Madhu Ranjan picture Madhu Ranjan · Jan 9, 2017 · Viewed 25.2k times · Source

How to include assets from external library into Angular CLI project

I am trying below but this does not work,

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

Scripts are working fine though,

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

Angular Version : 2.4.1

Angular CLI : 1.0.0-beta.24

Any suggestion?

Answer

luvaas picture luvaas · Apr 17, 2017

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/"
  },