how to deploy angular2 app built using angular-cli

后端 未结 9 823
误落风尘
误落风尘 2021-01-30 07:05

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 --

9条回答
  •  情歌与酒
    2021-01-30 07:43

    method 1(popular one) : If you are using angular-cli, then

    ng build --prod
    

    will do the trick. Then you can copy everything from .dist folder to your server folder

    method 2 :

    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 :)

    Bonus : If you want to deploy in heroku. Please go through this detailed tutorial https://medium.com/@ryanchenkie_40935/angular-cli-deployment-host-your-angular-2-app-on-heroku-3f266f13f352

提交回复
热议问题