DanyDin1801 / Product-Portal

0 stars 2 forks source link

Using nodemon in development for automatically restarting server #6

Closed vinaypuppal closed 8 years ago

vinaypuppal commented 8 years ago

I would suggest to use nodemon for development and add one more script to package.json "dev": "nodemon server.js". So we can run npm run dev on development machine and need not restart server manually whenever server side code changes.

rhgksrua commented 8 years ago

I would also go with nodemon. I approve.

JordyVlassembrouck commented 8 years ago

Nodemon does create some overhead though. When we change client side code, we don't want to restart the entire server. Right now, this won't be an issue when developing, but once we have a larger codebase, this can get annoying. Is there any possibility to use Nodemon for Server side code only and use a live reload framework for client side code?

vinaypuppal commented 8 years ago

@JordyVlassembrouck read about nodemon features and docs here you can ignore files or directories by providing options to nodemon . But i think we will run nodemon server.js so it will only watch server.js file and any files we import inside server.js file as far as i know. Just test it with sample project and let us know here if any issues we may have if we use nodemon

JordyVlassembrouck commented 8 years ago

@vinaypuppal Nodemon looks great for development. You'll have to create a server folder with the server.js file included, I reckon, and set a watcher on that folder to check all the files that run on the backend. I'll create another issue to implement live reload.

JordyVlassembrouck commented 8 years ago

@vinaypuppal reviewed and approved :white_check_mark:

vinaypuppal commented 8 years ago

@rhgksrua @JordyVlassembrouck which would be better, moving server.js to server/ folder and using nodemon to watch that folder or ignoring public/, test/ and html/ folders in nodemon process, so nodemon will watch entire root folder except files inside ignored folders. For me keeping server.js at root of project and ignoring client side folders seems better option. Any suggestions??

arreche commented 8 years ago

I would vote for moving the server.js into a server/ directory... But I think that we don't need any kind of server reloading at this moment.

rhgksrua commented 8 years ago

We can move all server related files into server/ directory. But server reloading will make things a lot easier since we'll need to make some api endpoints for our server. Keep in mind that using nodemon is completely optional. You don't have to use it if its too much.

vinaypuppal commented 8 years ago

@rhgksrua i thought this would be better file structure to follow. And yes nodemon would be optional, it is to make developer/developing experience better.

rhgksrua commented 8 years ago

You should create a new issue to talk about project structure. I'm just saying we can have nodemon as a dev dependency and let people decide if they want to use it or not.

JordyVlassembrouck commented 8 years ago

@rhgksrua +1 @vinaypuppal It is a good practice to separate everything that you can. I would separate every server side code in server/ and client code in public/ or anything else. I also like your article about project structure. I'll take a closer look at it tomorrow and maybe we can work something out.

vinaypuppal commented 8 years ago

Merged and closed