Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add extra grunt tasks? (e.g. grunt-reload) #22

Closed
nagyv opened this issue Oct 25, 2012 · 4 comments
Closed

how to add extra grunt tasks? (e.g. grunt-reload) #22

nagyv opened this issue Oct 25, 2012 · 4 comments

Comments

@nagyv
Copy link

nagyv commented Oct 25, 2012

hi,

I'm relatively new to grunt and especially to lineman, and would like to add the grunt-reload task to my lineman project

I've npm install grunt-reload, and wrote my config/application.js as follows:

module.exports = require('lineman').config.extend('application', {
  //Override application configuration here
  reload: {
        port: 6001,
        proxy: {
            host: 'localhost'
        }
    },
  watch: {
    js: {
      files: ['<config:files.glob.js.vendor>', '<config:files.glob.js.app>'],
      tasks: 'configure concat:js reload'
    },
    coffee: {
      files: '<config:files.glob.coffee.app>',
      tasks: 'configure coffee configure concat:js'
    },

    jsSpecs: {
      files: ['<config:files.glob.js.specHelpers>', '<config:files.glob.js.spec>'],
      tasks: 'configure concat:spec reload'
    },
    coffeeSpecs: {
      files: ['<config:files.glob.coffee.specHelpers>', '<config:files.glob.coffee.spec>'],
      tasks: 'configure coffee configure concat:spec'
    },

    css: {
      files: '<config:files.glob.css.app>',
      tasks: 'configure concat:css reload'
    },
    less: {
      files: '<config:files.glob.less.app>',
      tasks: 'configure less configure concat:css'
    },

    handlebars: {
      files: '<config:files.glob.template.handlebars>',
      tasks: 'configure handlebars configure concat:js reload'
    },
    underscore: {
      files: '<config:files.glob.template.underscore>',
      tasks: 'configure jst configure concat:js reload'
    },

    images: {
      files: ["<config:files.glob.img.app>", "<config:files.glob.img.vendor>"],
      tasks: 'configure images:dev reload'
    },
    homepage: {
      files: '<config:homepage.template>',
      tasks: 'configure homepage:dev reload'
    },

    lint: {
      files: '<config:files.glob.js.app>',
      tasks: 'configure lint'
    }
  }
});

simply to add the reload task to some sections.

Using it fails though. To reproduce, I've started lineman run and modified a js or template file:

Running "watch" task
Waiting...OK
>> File "app/templates/hello.us" changed.

Running "configure" task

Running "jst:compile" (jst) task
File 'generated/template/underscore.js' created.

Running "configure" task

Running "concat:js" (concat) task
File "generated/js/app.js" created.

Running "reload" task
File updated. Reload triggered.

Running "watch" task
Waiting...Got error: connect ECONNREFUSED

when I set the port to 8000 (where the watch server serves), I got no errors, but reload still does not happen.

I would like to run grunt-reload to reload the browser when less and css files change. Of course, I could use guard for this but it would be nice to have just a single tool.

@nagyv
Copy link
Author

nagyv commented Oct 25, 2012

I forgot to add that I've create a reload task under tasks/reload.js containing:

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-reload');
};

@davemo
Copy link
Member

davemo commented Oct 26, 2012

Hey @nagyv, thanks for the report. I've tried to reproduce this error without success (I also couldn't get grunt-reload working at all though, but I can't get your errors to show up in my console). Could you provide me with a bit more information about your environment?

What version of node/npm are you running?
What version of Lineman (and Grunt) do you have installed?
Mac? Windows? Linux?

As a general note, I've talked with @searls and we do want to add an option for reloading the browser when the watch process detects file changes, we just want to make sure it's easy to do and doesn't involve having to override so many config options :)

@nagyv
Copy link
Author

nagyv commented Oct 26, 2012

node 0.8.2
lineman 0.2.3
grunt 0.3.16
grunt-reload 0.1.2
Linux

if you plan reloading, I've checked out already many projects that provide it. From a usability point of view, the best solution so far is the one from livereload - guard-livereload. Especially due to its browser plugins. Even though I did not manage to get it working grunt-reload seems to be OK compared to the existing solutions, and is quite mature and feature rich.

Do you get any errors when trying to get grunt-reload to work?

@nagyv
Copy link
Author

nagyv commented Oct 31, 2012

so, let's move here the discussion on making livereload a core functionality or not :)

@davemo davemo closed this as completed Apr 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants