How to deploy Angular 2 application developed in Typescript to production?

前端 未结 6 718
情深已故
情深已故 2020-12-05 01:47

I am new to Angular 2. I am confused with how Angular 2 works in production environment.

  1. What are the prerequisites for running Angular 2 application in pr

6条回答
  •  死守一世寂寞
    2020-12-05 02:54

    it's very simple to upload app on production. steps:

    1. create an app using follow https://angular.io/docs/ts/latest/guide/webpack.html
    2. if your app has router then don't forget to use {useHash: true} for prevent the error can't load the page. like:

      RouterModule.forRoot(routes, { useHash: true })

    3. type npm build in your project root path.

    4. it create dist folder automatically in project root directory.
    5. don't need to setup node server on production. you can simply choose apache server and upload dist folder content.

提交回复
热议问题