Chris Smith
Chris Smith

Reputation: 3012

Expose node_modules file as an asset

I'm writing an app that provides an embed code to users. That embed code has some JavaScript dependencies I got off of npm.

In order to expose it, I first thought would be to simply copy the file from node_modules into the assets folder. However, this means I must re-copy the file each time the package is updated. (and I just don't like it, you know what I mean ;))

What I'd like to do is specify that file as an asset:

"assets": [
  "assets",
  "../node_modules/thepackage/dist/thefile.min.js"
]

However, this doesn't work as these three URLs just take me to the Angular app:

Any ideas, or is this something that is not supported (yet)?

Upvotes: 1

Views: 923

Answers (1)

Chris Smith
Chris Smith

Reputation: 3012

Since this commit, it is now possible.

Use this as your assets:

"assets": [
  "./assets",
  {
    "glob": "thefile.min.js",
    "input": "../node_modules/thepackage/dist/",
    "output": "./assets/js/"
  }
]

Upvotes: 2

Related Questions