grunt contrib watch - Get livereload to work with Sails.js -


i new both sails , grunt might missing obvious. trying automatically refresh sails app in browser whenever files change.

i start app sails lift , runs on default port 1337.

i tried adding options: {livereload:true} grunt-contrib-watch configuration far understand need somehow inject livereload javascript page?

i tried use grunt-contrib-connect livereload option inject javascript seems start server. when navigate started server (localhost:8000) see folder structure. livereload javascript injected however.

i want avoid livereload chrome plugin if possible.

what's best way inject livereload javascript sails app? or should use tool browsersync?

thank you! :)

  1. add livereload option tasks/config/watch.js
    module.exports = function(grunt) {       grunt.config.set('watch', {         api: {              // api files watch:             files: ['api/**/*', '!**/node_modules/**']         },         assets: {              // assets watch:             files: ['assets/**/*', 'tasks/pipeline.js', '!**/node_modules/**'],              // when assets changed:             tasks: ['syncassets' , 'linkassets']         },         // add          options: {           livereload: true,         },     });      grunt.loadnpmtasks('grunt-contrib-watch'); }; 
  1. add livereload script layout, somewhere @ end before </body> tag, default views/layout.ejs:
<script src="http://localhost:35729/livereload.js"></script> 

except of localhost can use ip or dns name of server

this refresh page if file changed in api or assets folder.

by default ggrunt-contrib-watch uses 35729 port. can point other port livereload: 8000

edit: well, not know if totally correct, looks can override layout settings in config/env/development.js. add like:

module.exports = {     views: {         layout: 'dev'     } } 

then can create separate layout file views/dev.ejs can add livereload script , other development params. can add livereload key in same way.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -