Current Correct Answer:
The team has added support for copying specific files as-is to the output folder (dist
by default) in a later version of Angular CLI (would be beta 17 or 19 - it's been in final 1.x releases for ages).
You just add it to the array in angular-cli.json
like:
{
...
"apps" [
{
"root": "src",
"assets": [
"assets",
"web.config"
],
...
}
]
...
}
(Note that the path is relative to the src
folder)
I personally use it and it works just fine.
As of beta 24, I have added a feature to Angular CLI that makes sure all assets
files and folders are served from the webpack dev server when running ng test
not just ng serve
.
It also supports serving the asset files in the webpack dev server used for unit tests (ng test
).
(in case you need some JSON files for the tests, or just hate to see 404 warnings in console).
They are already served from ng e2e
because it runs a full ng serve
.
And it has more advanced features as well, like filtering what files you want from a folder, and having the output folder name be different from source folder:
{
...
"apps" [
{
"root": "src",
"assets": [
"assets",
"web.config":
{
// Copy contents in this folder
"input": "../",
// That matches this wildcard
"glob": "*.config",
// And put them in this folder under `dist` ('.' means put it in `dist` directly)
"output": "."
}
],
...
}
]
...
}
You can also refer to the official documentation: Angular Guide - Workspace configuration
.
.
[FOR ARCHIVING ONLY] Original Answer (Oct 6, 2016):
This is not supported currently unfortunately (as of beta-16). I raised the exact concern to the team (web.config files), but it doesn't seem to be happening any time soon (unless you are forking the CLI, etc).
Follow this issue for full discussion and possible future details.
For the JSON file, you can put it in ./src/assets/
. This folder gets copied as-is to ./dist/assets/
. This is the current behaviour.
Earlier in systemJS days there was another ./public/
folder that got copied to ./dist/
directly, but this is gone in Webpack versions, which the issue referenced above discusses.
"copy:webConfig": "node node_modules/copy/bin/cli.js web.config dist"
. I also added a post build script:"postbuild": "npm run copy:webConfig"
. There were other issues trying to get the copy to work, but this did the trick. – Kizmar