Skip to content

index.html is rebuilt infinitely in watch mode, if it is right in the outputPath path #23923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
zanctor opened this issue Sep 16, 2022 · 5 comments
Closed
1 task done

Comments

@zanctor
Copy link

zanctor commented Sep 16, 2022

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.2.1

Description

If index path in angular.json lies right under the outputPath (ex. index is public/index.html and outputPath is public), it will cause infinite rebuilding of index.html when the --watch option is used.

Probably caused by #23852.

Minimal Reproduction

  1. Create a new workspace with ng new testapp with default settings.
  2. Open testapp/angular.json and change the outputPath option to src.
  3. Run cd testapp && ng build --watch --no-delete-output-path and wait for initial build to finish.
  4. Observe the result.

Exception or Error

No response

Your Environment

Angular CLI: 14.2.2
Node: 14.19.1
Package Manager: yarn 1.22.10 
OS: darwin x64

Angular: 14.2.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, upgrade

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.1
@angular-devkit/build-angular   14.2.1
@angular-devkit/core            14.2.2
@angular-devkit/schematics      14.2.2
@schematics/angular             14.2.2
rxjs                            7.5.6
typescript                      4.6.4
webpack                         4.46.0

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

Hi @zanctor,

I am a bit confused by the steps above, as based on your explanation you are configuring both input and output to map to the same path public/index.html.

In this case we should likely throw an error that the inputs will be overridden as this should never happen.

@zanctor
Copy link
Author

zanctor commented Sep 16, 2022

@alan-agius4, I've got a real use case for that.
Let's say we have a hybrid AngularJS + Angular app, where both parts are bundled separately since you can't bundle both together at once in some cases. So we build the AngularJS part first with its own index.html, then we build Angular codebase using the already built index.html. As a result, we have index.html, which loads both parts. That's why I used the --no-delete-output-path option to make Angular CLI modify the contents of index.html, not overwrite them.

@alan-agius4
Copy link
Collaborator

Just had a chat with @clydin about this.

Our recommendation is to place the AngularJS output in a different directory and keep the inputs and outputs of the Angular CLI separate and use the assets option to copy an additional files that are needed.

The fact that your setup previously work was due to the index file was not being watch, which was a bug and oversight on our end.

@zanctor
Copy link
Author

zanctor commented Sep 19, 2022

@alan-agius4, makes sense. I will close the issue.
Thanks!

@zanctor zanctor closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2022
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants