I have been creating web application using Angular 2 and Firebase, I want to enable production mode.
main.ts
if (environment.production) {
enableProdMode();
}
environment.ts
export const environment = {
production: true
};
environment.prod.ts
export const environment = {
production: true
};
Then I'm tried ng build -prod; ng serve ,but still not working.
Thanks in advance.
Simply check the production variable present in the environment file, it will be true for production mode and false for development.
enableProdModelink function. Disable Angular's development mode, which turns off assertions and other checks within the framework.
Development build produces source map files whereas production builds not. Source map files help us easily debug our application even after the files are compressed and compiled.
Production Mode The Production Mode of the project is where you have access to the finalized version of your data models & datasets that are ready for end-users to explore and build reports. You cannot make changes to project files when you are on Production Mode.
ng serve --prod
didn't worked for me.
This worked btw 😊
ng serve --configuration=production
it creates a test production server which works same as it works on the deployed one. I tried this testing with environment.js (all other solutions didn't worked for me)
You can follow this (Becoming an Angular Environmentalist) article to learn more about Angular environments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With