Download a cookie to work with Sails.js

I am new to both sails and grunt so I can skip the obvious. I'm trying to automatically update my sails application in the browser whenever the files change .

I run the application with sails lift and it runs on the default port 1337 .

I tried adding options: {livereload:true} to my grunt-contrib-watch configuration, but as far as I understand, do I need to somehow insert JavaScript into my personal page?

I tried using grunt-contrib-connect with the livereload option to enter JavaScript, but it seems to just start another server. When I go to the running server ( localhost:8000 ), I just see the folder structure. However, JavaScript is being introduced into JavaScript.

I want, if possible, to avoid Chromeel Chrome for download.

What is the best way to embed JavaScript to load into a Sails application? Or should I use another tool like Browsersync?

Thanks!:)

+5
source share
2 answers
  • Add cookie option for tasks /config/watch.js
  module.exports = function(grunt) { grunt.config.set('watch', { api: { // API files to watch: files: ['api/**/*', '!**/node_modules/**'] }, assets: { // Assets to watch: files: ['assets/**/*', 'tasks/pipeline.js', '!**/node_modules/**'], // When assets are changed: tasks: ['syncAssets' , 'linkAssets'] }, // ADD THIS options: { livereload: true, }, }); grunt.loadNpmTasks('grunt-contrib-watch'); }; 
  1. Add a script cookie to your layout, somewhere at the end before the </body> , by default views / layout.ejs:
 <script src="http://localhost:35729/livereload.js"></script> 

With the exception of the local host, you can use the IP or DNS name of the server

This will refresh the page if the file is modified in the api or assets folder.

By default, Ggrunt-contrib-watch uses port 35729 . You can specify a different port, for example livereload: 8000

EDIT: Well, I really don't know if this is completely true, but it looks like you can override the layout settings in config/env/development.js . Add something like:

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

Then you can create a separate views/dev.ejs layout file in which you can add a script cookie and other development options. You can also add the livereload key in the same way.

+6
source

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

It works like a charm.

+1
source

All Articles