Tuesday 6 June 2017

Problems when bringing node with angular

I am using angular4. I used angular-cli to create my project.

I want to use node.js as server side language with mongodb. So, I found a tutorial here to connect node.js with angular.

But there are two problems with it:

  1. dist folder is created.
  2. auto refresh server like using nodemon or similar is lost

problem with dist folder

My site depends heavily on images. I keep all the images in a folder called images which is located under assets folder created by angular-cli

So, when I run the server, all the assets will be copied to the dist directory, which will take time and (more important) space on the webserver. Another problem is that If I upload new images, then it will be copied to the images folder inside dist folder, so I have to manually copy those images to my original dist folder.

Another copy of images folder in dist folder will take double space than my original app. So, I have to pay more money for hosting to use more space.

problem with auto-refresh server

before using node, I just typed this command

ng serve

and my application started. Then when I change any code and save the file, the changes were reflected in the browser without restarting the server.

But when I started to use node, I have to manually restart the server whenever I make changes to my code.

Question:

Is there any way that prevents app to create images folder inside dist folder to save space. I mean can I use original Images folder instead of creating one inside dist?

Or is there any other way that a node application and angular application work together?



via Vishal

No comments:

Post a Comment