1

How can I auto reload the client side files such as the .ejs and the javascript files?

I have tried using forever but it seems to only autoreload the models and controllers.I'm looking for a way to auto-reload the client side files.

Matan Gubkin
  • 3,019
  • 6
  • 25
  • 44
  • 1
    What version of sails are you using? The latest version does this by default, you should check your code in /tasks/config/watch.js and make sure your javascript files are in the /assets folder – VladNeacsu Jun 01 '15 at 07:36

3 Answers3

1

For now, that can not be done. Only models, controllers, views and services files are reloaded. All other can be reloaded only manually.

https://www.npmjs.com/package/sails-hook-autoreload

Anyway I do not see the problem. Only configs and static files are not updated. That is done by Grunt at server startup. And you do not need to do it often, so you can manually restart server.

Bulkin
  • 1,020
  • 12
  • 27
  • my views aren't auto reloading.... im using the command forever -w start app.js to lift my sails app – Matan Gubkin May 31 '15 at 20:31
  • Did you install [sails-hook-autoreload](https://www.npmjs.com/package/sails-hook-autoreload)? – Bulkin May 31 '15 at 20:47
  • its not working on my /views. I need a solution for the views. – Matan Gubkin Jun 02 '15 at 12:20
  • @MatanGubkin What version of sails are you using? Are you sure you have sails-hook-autoreload installed? Did u run `npm install sails-hook-autoreload` in root dir of project? Check if *.ejs* is turned on in _config/views.js_. I have just checked on Sails.js v0.11 - everything works just fine – Bulkin Jun 02 '15 at 12:34
  • i am using sails 0.11.0. I did run sails-hook-autoreload in my root dir and my view engine is configured to be ejs by default. Controllers, Models and Services are all auto-reloading. I need a way to auto-reload my .ejs views. – Matan Gubkin Jun 02 '15 at 12:37
  • @MatanGubkin Try to remove `-w` key, let Sails do the work. On my installations Sails and Forever conflicting if let Forever to restart server on file updates. Anyway, if start `forever -w`, you must at least add `--watchIgnore .tmp` for Sails projects. So first of all try to simply start `forever start app.js` – Bulkin Jun 02 '15 at 12:55
  • @MatanGubkin I am confused. I checked several times. On my present projects and new created. Everywhere all of files, except configs, are refreshing. So I really can not repeat your problem. – Bulkin Jun 03 '15 at 06:29
  • @MatanGubkin Let's define more accurately. If you are talking about files in **assets** dir, then no, they are not refreshed. They are copied to .tmp dir at server start, so you may [try this solution](http://stackoverflow.com/questions/18687818/auto-reloading-a-sails-js-app-on-code-changes), but I am not sure as that post is for old versions of [tag:sails.js]. So may be you better ask the question on [IRC channel](http://sailsjs.org/#!/support/about-irc) – Bulkin Jun 03 '15 at 06:41
  • My views are not refreshing. I'm not talking about the assets folder just to make it clear. Perhaps it has to do to the fact that I installed sails auth? – Matan Gubkin Jun 03 '15 at 08:29
  • I am totally confused. Really do not know how I can help. The only way I see is to ask question on IRC. – Bulkin Jun 03 '15 at 12:44
0

I managed to solved it.

auto reload doesn't work on production mode. Only on development

Matan Gubkin
  • 3,019
  • 6
  • 25
  • 44
0

After lost some time trying do this with sails/grunt, i install the livereload browser plugin (http://livereload.com/extensions/) for .html, js and css and the package (https://www.npmjs.com/package/sails-hook-autoreload) for the models and controllers.

It has another way in the link follow:

Get livereload to work with Sails.js

Community
  • 1
  • 1
Liko
  • 2,130
  • 19
  • 20