ng build does not create index.html if "index" property is changed in .angular-cli.json
Bug Report or Feature Request (mark with an x)
- [x ] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.2.0
node: 8.1.2
os: darwin x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/service-worker: 1.0.0-beta.16
@angular/cli: 1.2.0
@angular/compiler-cli: 4.2.4
@angular/language-service: 4.2.4
Repro steps.
Change the path of index property in .angular-cli -> apps[0] to a different path
for example : "index" : "index.html" -> "index": "app-loader/app1/index.html"
The log given by the failure.
index.html file is not created in the "outDir" folder.
Desired functionality.
index.html should be present
Mention any other details that might be useful.
My use is such that we have a common monorepo that has all the components and we package them as different apps based on requirements.
We have a similar issue. We have multiple apps defined in angular-cli, each with its own root dir, but we wanted to reuse the same index.html
"root": "src/app1",
"outDir": "dist",
"index": "../index.html",
Everything builds just fine in the dist folder, except the index.html which is outputed in the project root.
The source of this issue is in: https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/models/webpack-configs/browser.ts#L57
When reading the template index.html the path is resolved relative to the appRoot, and when outputing it the path is resolved relatiev to the outputPath.
template: path.resolve(appRoot, appConfig.index),
filename: path.resolve(buildOptions.outputPath, appConfig.index),
In our case I think we will just copy the index.html in every app root.
In your case it's probably trying to output it in dist/app-loader/app1/index.html. Maybe you should consider using the "root" property as well.
Regarding a more generic solution: Maybe we can specify a glob pattern for the index? like with assets
// my scenario with index in the root
"index": { "glob": "index.html", "input": "../", "output": "./" }
// your scenario
"index": { "glob": "index.html", "input": "./app-loader/app1/", "output": "./" }
This sounds to me as working as intended. Overall in the CLI we try to respect relative paths, so if you provide a relative path for index, it is used. App root is used as a base and we don't remap index.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.