how to deploy angular2 app built using angular-cli

后端 未结 9 831
误落风尘
误落风尘 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:46

    http-server doesn't support client-side routing, so nothing other than your base URL is going to work. Instead, you can use angular-http-server:

    npm install -g angular-http-server
    ng build --prod
    cd dist
    angular-http-server
    

    This should only be used to test the app locally before deploying it on a Web server. To learn how to actually deploy the app on a Web server, check out the Angular.io article on deployment, which discusses considerations to make when building for deployment and provides configurations for a variety of different Web servers commonly used in production.

提交回复
热议问题