Angular2 compilation for production

How to compile Angualar2 and deploy it for production? I checked many websites such as This (but this gives an error, but bundle.min.js cannot be used from index.html - maybe I am wrong) Also tried angular-cli, but again for RC-4 it doesn’t works.

I wonder what are the best practices, because tsc already creates js if they just are imported as a separate file (this will be ugly for that).

PS: There are already questions related to this topic, for example. But this is a basic requirement that I cannot answer.

+5
source share
3 answers

I got my final answer, believe me, I tried all of the above. Maybe dont worked for me except https://github.com/preboot/angular2-webpack . Worked loved charm. Recommended for others. See My Release Chain https://github.com/preboot/angular2-webpack/issues/120 . [SOLVED]

0
source

First step:

First run the command in ng-cli

 ng build 

or

 ng build -prod (then it will compact all files for production version) 

Second step:

Edit in index.html in dist directory

 <base href="/"> to <base href="./"> 

Third step:

Put all the files on the server (maybe htdocs on the local host or on any server)

Hope this works.

0
source

With Angular-cli

ng serve --prod --aot to test the production version on the local machine.

ng build --prod - List the assembly for deploying prod using AOT.

0
source

All Articles