3

My production build of my Angular2 app using Angular CLI with WebPack needs some files copied to the dist folder so I can deploy the app to our production (IIS) server. Specifically, I need web.config and favicon.ico files copied from src folder to dist folder. The web.config file is necessary so I can apply URL Rewrite rules for html5 routes.

I'm assuming we need to add these static files to angular-cli.json file, but not sure where to list these files so they are included in production build.

Thanks in advance.

Tom Schreck
  • 5,177
  • 12
  • 68
  • 122
  • Can you use the assets option? eg ``` { "project": { "version": "1.0.0-beta.14", "name": "client" }, "apps": [ { "assets": "assets", ... ``` – shusson Sep 20 '16 at 01:13
  • web.config has to be copied to root where index.html resides. It's my understanding assets get copied to assets folder. – Tom Schreck Sep 20 '16 at 06:45
  • I guess this issue is relevant: https://github.com/angular/angular-cli/issues/1942 – Yuri Sep 20 '16 at 16:20
  • @Yuri. Thanks for the link. looks like there is no fix for this issue. hopefully it will get fixed soon – Tom Schreck Sep 20 '16 at 16:58
  • Possible duplicate of [How to include custom files with angular-cli build?](https://stackoverflow.com/questions/39538464/how-to-include-custom-files-with-angular-cli-build) – Heretic Monkey Oct 24 '18 at 18:17

1 Answers1

2

Currently (angular-cli v1.0.0-beta.26), if you want to copy files and folders to a build, you can list them in assets property in ./angular-cli.json config file.

"assets": [
  "web.config",
  "favicon.ico",
  "some_file",
  "some_folder",
  ...
]

Example of the config in a gist.

Place the web.config and favicon.ico files to ./src/ folder of your project. You should be able to serve them from urls /web.config and /favicon.ico.

If you include folders, they'll need to be a part of the url, i.e. /some_folder/some_subfolder/another_file.txt.

Angular-CLI README

Similar answer

Community
  • 1
  • 1
mrkvon
  • 3,507
  • 2
  • 21
  • 26