3
votes

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.

1
Can you use the assets option? eg ``` { "project": { "version": "1.0.0-beta.14", "name": "client" }, "apps": [ { "assets": "assets", ... ```shusson
web.config has to be copied to root where index.html resides. It's my understanding assets get copied to assets folder.Tom Schreck
I guess this issue is relevant: github.com/angular/angular-cli/issues/1942Yuri
@Yuri. Thanks for the link. looks like there is no fix for this issue. hopefully it will get fixed soonTom Schreck

1 Answers

2
votes

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