-
Notifications
You must be signed in to change notification settings - Fork 687
Show how to use multiple environments (for browser and prerender) #673
Comments
I just tried this:
added two lines to server.ts
it says environment.production is false. Seems like there's a bug in the universal-starter? |
Anyone got this working? |
I got working using the code above for Angular 6 which is older webpack config. |
alright, I finally got this working. The code is inspired by @kmturley and https://webpack.js.org/plugins/normal-module-replacement-plugin/ ` const path = require('path'); module.exports = function (env) {
}; The script supports 2 environments - local and production. You can easily extend it with other envs. |
In your angular.json, you show how to use file replacement for environments:
https://github.com/angular/universal-starter/blob/master/angular.json
In your package.json
https://github.com/angular/universal-starter/blob/master/package.json
You show a shorthand for production configuration builds using --prod:
This works if you import an environment in browser code like your main.ts:
https://github.com/angular/universal-starter/blob/master/src/main.ts
But this doesn't work when the same code is used in prerender.ts:
Even if you add fileReplacement to angular.json "server" configuration:
In my Angular 6 version I had to work around this using multiple webpack configs and a webpack file replacement:
Do you have a solution when using the typescript compiler?
"compile:server": "tsc -p server.tsconfig.json"
The text was updated successfully, but these errors were encountered: