I am in the process of developing an Angular application and have a question regarding ensuring the build fails in production but not during local development.
Specifically, I have a complex login logic that I would like to bypass while working on it. To achieve this, I simply need to add a single line in app.component.ts
:
ngOnInit(): {
this.userservice.mockLoginUser();
...
}
Is there a way to ensure this line runs during development mode but causes a failure if overlooked in the production build? For example, is there a command that only triggers an error with ng build --prod
(but not with ng serve
)?
I do not wish to use environment.ts
as I want to avoid cluttering the codebase; I aim to physically delete it along with the mockLoginUser
method since it's only required occasionally. Another thought was creating a tslint rule to prevent it from reaching production, although I haven't found any suitable options yet.