I have created n new angular app using angular-cli.

I completed the app and preview it using ng-serve, it is working perfectly.

After that I used ng build --prod, that generates the 'dist' folder. When I put that folder in xampp to run, it is not working. I found that there is no *.js files, which should be in there after *.ts -> *.js conversion (i suppose).

I have attached the screenshot, in which on left side it is showing the src folder having all .ts files, On middle it is showing the 'dist' folder and browser screenshot.

Please guide me how can I generate fully working app from angular-cli, which I can run in my xampp server. Screenshot

share|improve this question
    
What version of angular-cli? Are you using --mobile and angular-universal? – Splaktar Jun 22 at 5:31

Well I was also looking for a solution like you. What I have come across is I am sharing with you -

you can use http-server to serve your app . To install http-server

npm install http-server -g

and after going to your project folder

http-server ./dist 

it will serve all the files in your folder. you can check the terminal what ip-address and port you can use to access the application. Now open up your browser and type

ip-adress:port/index.html

Hope it will help you :)

share|improve this answer
    
works, but first with angular cli you must build your project using ng build – Nather Webber Oct 26 at 12:03

For anyone looking for an answer for IIS hosting...

Build your project

ng build --prod

Copy all contents of the ./dist folder into the root folder of your website maintaining the folder structure within ./dist (ie - don't move anything around). Using the Beta-18 version of the angular-cli all assets (images in my case) were copied to ./dist/assets during the build and were referenced correctly in their containing components.

share|improve this answer
    
So you deploy the .gz and .map files as well? – EdL Nov 8 at 17:14
1  
On IIS you don't have to deploy the .gz files, just configure IIS to use dynamic compression, you can save a lot of bytes going over the wire. The .map files are source maps. Think of them as the .pdb's of the javascript world, so yes, if you want to debug on the server you're deploying to. Uglifying the JS makes debugging really hard (read:impossible) without them. – Mike Devenney Nov 8 at 19:27

I'm using the latest version of the Angular-CLI (at the time of this reply its 1.0.0Beta-18)

The way this version works is it puts everything in bundle files and it calls them in the index.html file. After that you have to copy your assets over to the dist folder (for some reason it does not do that). Finally, double check your base href make sure its set to what it needs to be set to and then it should work. That's what worked for me and I've tested on both Apache and Node.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.