admin管理员组文章数量:1405192
I used the new Angular Universal Starter to start a new Angular 5 project. For the new release they only give the Angular CLI version as a starter.
Everything works fine and I can run my project in production with npm run serve:ssr
etc.
But: I have a custom API for the node.js/express server that acts as a wrapper for my backend.
When starting the project in development with ng serve
or npm run start
I have a working Angular application with automatic reload on file changes etc.
Unfortunately in development the server.ts
file is ignored, so my API wrapper is not available.
So did anyone get the new Angular Starter Kit up and running with the server.ts
file used in development?
I used the new Angular Universal Starter to start a new Angular 5 project. For the new release they only give the Angular CLI version as a starter.
Everything works fine and I can run my project in production with npm run serve:ssr
etc.
But: I have a custom API for the node.js/express server that acts as a wrapper for my backend.
When starting the project in development with ng serve
or npm run start
I have a working Angular application with automatic reload on file changes etc.
Unfortunately in development the server.ts
file is ignored, so my API wrapper is not available.
So did anyone get the new Angular Starter Kit up and running with the server.ts
file used in development?
2 Answers
Reset to default 5As of now angular cli does not support universal to run in dev mode. You can try nodemon if watching changes is what you need:
nodemon --ignore dist -e ts --exec 'npm run build:ssr && npm run serve:ssr'
It will restart every time you change a .ts file, but it will build the whole application again, so it is not fast.
On Github FriOne mentioned a better workaround using ts-node-dev
:
ts-node-dev --fast --respawn server.dev.ts
To run this I duplicated the server.ts file to server.dev.ts only with the APIs I need to access while in dev. this way you can use ng serve
for fast rebuilds while developing and still access your node-apis.
本文标签: javascriptAngular 5 Universal Using serverts in DevelopmentStack Overflow
版权声明:本文标题:javascript - Angular 5 Universal: Using server.ts in Development - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744881534a2630235.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论