0

I have angular-cli project with 3 environments files:

 1. environment.prod.ts
 2. environment.dev.ts
 3. environment.stages.ts

I want to build project on the server(not put dist folder to the server, but run webpack build on server). I run ng eject to get webpack.config.js, but when i run webpack --env=prod or webpack --env=dev it make bundle only for environment.prod.ts, but i need to make bundle for other environment too. How can I do this?

P.S. First of all sorry for my bad English. If you don't understand what i need or if you need more information, please just ask me to correct my answer)

fiorebat
  • 3,431
  • 2
  • 18
  • 18
Belouccio
  • 300
  • 1
  • 3
  • 14
  • https://stackoverflow.com/questions/42387864/angular-cli-environment-file-replacement-is-broken-after-switch-to-webpack-wit I found this answer, but i don't know how specify NODE_ENV for each env. Can someone help me, please? – Belouccio Dec 14 '17 at 08:37
  • Set the `NODE_ENV` before webpack command. E.g. `NODE_ENV='production' webpack -p` – Gowrav Dec 14 '17 at 08:48
  • I try `npm run build NODE_ENV='dev'` and get TypeError: Cannot read property 'replace' of undefined at WebpackCompilerHost._normalizePath – Belouccio Dec 14 '17 at 09:22
  • maybe I do something wrong? I add `var NODE_ENV;` into my webpack.congif.js, cause without it, i get error `NODE_ENV` is not defined. But now in my editor NODE_ENV look like unused variable. – Belouccio Dec 14 '17 at 09:40
  • Thank you, Gowrav. Now workin fine, I just add `NODE_ENV=env` to `module.exports` in webpack.config.js. – Belouccio Dec 14 '17 at 14:55

0 Answers0