Monday, 8 May 2017

How to best organise NodeJS+Angular-cli project with a lot of share code?

I'm building NodeJS + Angular2/4 application with TypeScript where client and server have a lot of code in common. Currently, I have 3 separate folders:

  1. "client" - with Angular-cli project (has its own package.json)
  2. "server" - with node.js project (has its own package.json)
  3. "shared" - with shared TypeScript code (has its own package.json)

The first problem I realised was that when I want to start the project, each time I have to manually go into its client and server subfolders and run ng build --watch, npm start for server, tsc for shared. Would be nice to have some command to launch all the needed scripts both on the client and on the server at once if possible.

The second problem is that the path to shared folder is getting too long for both the client and the server. I've heard somewhere that it's possible to mark a directory as source root (same as node_modules) and later refer to its code simply by "module_name" without the long path. Can I do it with the setup I have?

Otherwise, is this kind of setup considered to be ok? Or is there a better solution for building NodeJS+Angular-cli apps?



via Daniil Andreyevich Baunov

No comments:

Post a Comment