5

How to compile the Angualar2 and deploy for production? I have checked lot of websites like This (but this gives error and bundle.min.js are not usable from index.html -maybe I am wrong). Also tried to angular-cli but again for RC-4 this is not working.

Wondering what is the best practices, because tsc already creates the js, should they just be imported as individual file (it will be ugly to do so).

PS: There is already questions related to this topic like these . But this is the fundamental requirement , which I am unable to get answer for .

Community
  • 1
  • 1
rajesk
  • 1,407
  • 1
  • 9
  • 8
  • See if this helps - https://angular.io/docs/ts/latest/guide/webpack.html#!#production-configuration – Sanket Jul 04 '16 at 05:43
  • have you seen [THIS](http://stackoverflow.com/questions/37631098/angular-2-how-to-bundle-for-production-currently-rc3/37874643#37874643) and [THIS](http://stackoverflow.com/questions/34614743/how-to-prepare-release-version-with-systemjs-and-gulp?rq=1) ? – Ankit Singh Jul 04 '16 at 07:53
  • Here is my [solution](http://stackoverflow.com/questions/35280582/angular2-too-many-file-requests-on-load/38168012#38168012) based on mgechev's repository. – FreeBird72 Jul 04 '16 at 08:36

3 Answers3

0

I got my final answer , trust me I tried eveything stated above. May be dint worked for me except https://github.com/preboot/angular2-webpack . Worked liked charm . Recommended for others. See my issue chain https://github.com/preboot/angular2-webpack/issues/120 . [SOLVED]

rajesk
  • 1,407
  • 1
  • 9
  • 8
  • Hi. Did you use angular2-webpack for an existing project you had or did you start from scratch? If it's the first option, would you mind sharing what you did to add a bit to the post? (and help me out a metric ton!) – monkey intern Aug 10 '16 at 09:32
0

First Step:

At first run the command in ng-cli

ng build

or

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

Second Step:

Change at index.html in dist directory

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

Third Step:

Put all files into server(may be htdocs in localhost or any server)

Hopefully it will work.

sabuz
  • 829
  • 8
  • 10
0

With Angular-cli

ng serve --prod --aot for testing the production version on the local machine.

ng build --prod --aot to generate build for prod deployment with AOT.

Praneeth Reddy
  • 424
  • 3
  • 7