0

I have an external npm module that looks for a specific file in the app's root directory (in the case of Angular, the dist/ folder). A relatively simple solution is to put that file there. However, I don't know of a way to do it: putting the path to the file in angular.json under scripts simply includes the script in main.js. Putting it under assets wouldn't solve this specific case either.

Is it possible to configure the built to include it in the dist folder as-is? (Angular 8)

2
  • In assets (in angular.json) you can also copy to the root. Doesn’t have to be inside the assets folder..? Commented Aug 13, 2020 at 14:56
  • @MikeOne thanks I thought of doing that, but is there a way to map the asset to the root path in dist? Including the original asset in the root folder just to have it in the correct dir seems a bit strange. Commented Aug 13, 2020 at 17:51

1 Answer 1

3

Figured it out: it looks like it's actually possible to specify assets not just as individual entries, but also as objects. It's actually in the documentation but I had previously missed it: https://angular.io/guide/workspace-config#asset-config

Therefore, the assets can look like:

"assets": [
    "src/assets",
    "src/favicon.ico"
]

But also something like this:

"assets": [
    "src/assets",
    "src/favicon.ico",
    {
        "glob": "**/*",
        "input": "path/to/my/custom/asset/dir/",
        "output": "/"
    }
]

This allows the mapping of an individual asset to an output path.

Sign up to request clarification or add additional context in comments.

1 Comment

Exactly. Great you found it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.