sailsjs live update during serverside editing
Asked Answered
S

2

9

It's annoying to have to restart the sails server when you change something, is there any way to make sailsjs do what meteor does where when you save a serverside file it automatically updates the clientside?

That's a pretty awesome feature, and I love sails but that feature is pretty cool.

Shiekh answered 4/10, 2013 at 5:55 Comment(1)
possible duplicate of Auto reloading a Sails.js app on code changes?Abominate
L
26

Nodemon is a helpful development tool that watches the files in the directory that it was started in, and if anything changes are detected, your node.js application will automatically restart.

To install nodemon (you may need to use sudo)

$ npm install -g nodemon

Sails.js continually writes to the .tmp folder, and as a result you will find that nodemon will continually restart the server. To resolve this issue, simply ignore this folder by creating a .nodemonignore file with this single line, noting you can place any other files/folders you wish to ignore on separate lines

.tmp/*

To run your Sails.js application through nodemon

$ nodemon app

For more information, be sure to check out nodemon on npmjs.org

Luting answered 8/10, 2013 at 14:52 Comment(3)
I found an npm package called live-reload, which sounds like it does what I want it to do, but I'm not sure. I want the server to push changes to the browser without having to click refresh. Also regardless the nodemon thing is super crazy helpful, thank you very much.Shiekh
Make sure you install sails locally (npm install sails)Broddie
I had to add .tmp/* and .views/* to my .nodemonignore to make this work in sails v0.11. This is because sails will edit your assets (<!--SCRIPTS-->) on build.Abominate
G
0

If you monitor nodemon --ignore 'tmp/*' --ext js,ejs . you will still get the infinite reload problem. Apparently Sails is constantly writing the ejs files.

Grant answered 15/11, 2014 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.