As almost all of the developers find it difficult to stop sails and run it again for any changes done in the code.
Today we will use a npm package which provides auto reloading of sails whenever there is a change in the code.
Let’s get started
1. Creating SailsJs Project
Follow the below tutorial for setting up SailsJs
Setting up sails project
2. Installing Packages
For this autoreload feature, we will be using sails-hook-autoreload package created by Scott Gress
To install the package use the below command
Now we can create a config file autoreload.js in config directory.
In this file you can define the code base changes for which you need the autoreload feature to work
Create a file autoreload.js in config (if not exist)
Paste the below code in config/autoreload.js
You can make changes in this file as per your need
For more info related to configuration you can explore the github repo
5. Start Sails
Now start your sails application using below command
This completes the setup of the autoreload package
You can find the source code for the tutorial at below URL
You can also watch the video which will show the live working of autoreload package