Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CLI & Angular Universal cannot get environment.production to be true on server with --prod

I set up my web app using the Universal Starter - here and am trying to use environment.production to switch between a production config and a development config inside ./src/config/server.config.ts but the value is always false. When I check the value inside a lazy loaded route the value is correct. What am I to do to get it to be the correct value server side?

any help is appreciated. thank you

like image 559
Lukas Sorensen Avatar asked Oct 21 '25 22:10

Lukas Sorensen


1 Answers

I think you want something with how you're configuring webpack and creating your environment in your npm scripts. You can set the environment based on your webpack configuration. Using webpack-merge you can have multiple configuration packages and by setting each one up to the values you have defined you can swap back in forth with webpack-merge in your npm scripts. Refer to the link below.

https://webpack.js.org/guides/production/

like image 156
Dylan Wright Avatar answered Oct 24 '25 13:10

Dylan Wright



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!