angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

file paths inside index.html do not support custom output paths

Open chrisguttandin opened this issue 6 years ago • 5 comments

🐞 Bug report

Command

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

I don't know for sure, but I don't think so.

Description

The CLI currently allows to modify the output path of the index.html file. This works fine. Unfortunately it only modifies the output path and doesn't modify the file paths which are used inside the index.html file to reference the JavaScript files.

🔬 Minimal Reproduction

  • create a new project npx @angular/cli new my-project
  • modify the angular.json at projects > my-project > architect > build > index
"index": {
    "input": "src/index.html",
    "output": "subdirectory/index.html"
}
  • run ng build
  • inspect the file located at dist/my-project/subdirectory/index.html
  • it references the JavaScript files as if they would be in the same folder

🔥 Exception or Error

It doesn't throw an error.

🌍 Your Environment


Angular CLI: 8.3.18
Node: 12.13.0
OS: darwin x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.18
@angular-devkit/build-angular     0.803.18
@angular-devkit/build-optimizer   0.803.18
@angular-devkit/build-webpack     0.803.18
@angular-devkit/core              8.3.18
@angular-devkit/schematics        8.3.18
@angular/cli                      8.3.18
@ngtools/webpack                  8.3.18
@schematics/angular               8.3.18
@schematics/update                0.803.18
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

I'm happy to provide a pull request for this if you agree that this is a bug.

chrisguttandin avatar Nov 09 '19 11:11 chrisguttandin

The main intentional of that option is to allow the renaming the index file and support of custom build and staging setups. These generally have a variety of additional options in use as well as custom pre/post processing steps. Modifying the content could cause such setups to fail. There is the potential to add an extra option that supports your scenario however the amount of usage may not warrant the long term cost of an additional option. Added the issue to the team discussion list.

clydin avatar Nov 09 '19 13:11 clydin

Thanks for the quick response @clydin.

Sorry, I didn't know that this was intended to only rename the file.

In case we would resolve the paths of all tags relative to the new location of the index.html that wouldn't change anything for anybody who just renames the file if I understand the concept correctly.

chrisguttandin avatar Nov 09 '19 14:11 chrisguttandin

At this point we're in a bit of a bind: we never intended that option to be used to move the file elsewhere, but we also didn't validate that it wouldn't.

Strictly speaking the bug is that we didn't validate the path but removing it now might affect some people so it might be better to not do anything.

Actually trying to support the new path would be a bigger endeavor for the reasons Charles listed. We want to come up with a better story for all things base href related, but don't yet have it.

filipesilva avatar Nov 14 '19 19:11 filipesilva

Thanks for looking into it.

Please don't worry too much about it. I just came across this and thought it's inconsistent and should be addressed. But I fully understand if you think it doesn't make sense to do so. Feel free to close this issue if you like.

chrisguttandin avatar Nov 15 '19 10:11 chrisguttandin

English is not my native language. I haven't seen this file since 2019. Sorry. Not know what to do .

Cachond1 avatar Feb 15 '24 13:02 Cachond1