Skip to content

HMR stories. configuration is not present in angular.json schema #10663

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
Dok11 opened this issue May 5, 2018 · 8 comments
Closed

HMR stories. configuration is not present in angular.json schema #10663

Dok11 opened this issue May 5, 2018 · 8 comments
Labels

Comments

@Dok11
Copy link

Dok11 commented May 5, 2018

https://github.com/angular/angular-cli/wiki/stories-configure-hmr

image

This key are not presented in https://github.com/angular/angular-cli/wiki/angular-workspace

@Dok11 Dok11 changed the title HMR stories. configuuration is not present in angular.json schema HMR stories. configuration is not present in angular.json schema May 5, 2018
@tinesoft
Copy link

tinesoft commented May 6, 2018

Hi,

I think it is just a typo, just replace with configurations instead.

Also, i had to remove the "fileReplacements" part because i was getting:

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(fileReplacements).

angular.json

        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "<YOUR-APP>:build",
            "hmrWarning": false
          },
          "configurations": {
            "production": {
              "browserTarget": "<YOUR-APP>:build:production"
            },
            "hmr": {
              "hmr": true
            }
          }
        }, 

note: the "hmrWarning": false is optional, i added it to get rid of the warning displayed by the cli (to remind you that you must add/modify additional files to have "hmr" truly working)

@Silthus
Copy link

Silthus commented May 6, 2018

But the documentation states that the environment.hmr.ts file must replace the environment.ts file. Without the fileReplacements that is not possible.

@tinesoft
Copy link

tinesoft commented May 6, 2018 via email

@Dok11
Copy link
Author

Dok11 commented May 6, 2018

Yes, later I found what HMR working without any manual configuration just with `ng serve --hmr

@clydin clydin added comp: cli/serve area: docs Related to the documentation labels May 8, 2018
@collinstevens
Copy link

Background

@tinesoft @Dok11 I've been able to get the message that HMR is running when using "ng s -c hmr --hmr", but it isn't properly switching to environments.env.ts.

It will still do full page refreshes because it is using the environments.ts. If I place "hmr": true inside of the environments.ts, it will actually do HMR because it is using it now..

This documentation, https://github.com/angular/angular-cli/blob/v6.0.0-rc.8/packages/%40angular/cli/lib/config/schema.json#L1324-L1518, is not giving me any insight on how to fix the issue from what I can read.

This documentation, https://github.com/angular/angular-cli/wiki/stories-configure-hmr, is out of date. The "fileReplacements" property is invalid; it is being kicked back by the @angular/cli.

Interestingly, running "ng -s -c production" will use environments.prod.ts, but I don't see this configured anywhere except on the "build" property for angular.json (in the fileReplacements property of the "build" object).

Solution

I've managed to find a solution, but I don't know if it is the official solution. This fixes the currently broken HMR story and assumes that you've completed it's steps.

Inside of angular.json under architect/build/configurations, add a configuration named "hmr". Add the fileReplacements property to replace your regular environment.ts with the environment.hmr.ts.

"hmr": {
  "fileReplacements": [{
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.hmr.ts"
  }]
}

You will also need to modify angular.json again under architect/serve/configurations. Add a configuration as follows:

"configurations": {
  "hmr": {
    "hmr": true,
    "browserTarget": "loan-depot-devtools:build:hmr"
  }
}

The architect/server/configurations/hmr/browserTarget property will cause the @angular/cli to use the architect/build/configurations/hmr/fileReplacements property.

Question

I'm assuming there is a new place to put the fileReplacements property in angular.json so that it will properly replace the environments files?

@wkjesus
Copy link

wkjesus commented May 23, 2018

Im agree with @collinstevens you need to do the configuration he talk about. the story must be update with this issue.

bniedermeyer added a commit to bniedermeyer/angular-cli that referenced this issue May 26, 2018
Update documentation for the hmr story to show proper
configurations in angular.json and src/tsconfig.app.json.

Closes angular#11028, angular#10668, angular#10663
bniedermeyer added a commit to bniedermeyer/angular-cli that referenced this issue May 26, 2018
Update documentation for the hmr story to show proper configurations
in angular.json and src/tsconfig.app.json.

Closes angular#11028, angular#10668, angular#10663
bniedermeyer added a commit to bniedermeyer/angular-cli that referenced this issue Jun 8, 2018
Update documentation for the hmr story to show proper configurations
in angular.json and src/tsconfig.app.json.

Closes angular#11028, angular#10668, angular#10663
filipesilva pushed a commit that referenced this issue Jun 12, 2018
Update documentation for the hmr story to show proper configurations
in angular.json and src/tsconfig.app.json.

Closes #11028, #10668, #10663
@filipesilva
Copy link
Contributor

Closed via #11029

filipesilva pushed a commit to filipesilva/angular-cli that referenced this issue Jun 13, 2018
Update documentation for the hmr story to show proper configurations
in angular.json and src/tsconfig.app.json.

Closes angular#11028, angular#10668, angular#10663
@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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants