Question

It seems that when the nodemon running ,the other tasks will be pending and not runned. How can I use both of them? or whether I can use nodemon to watch less files and compile them?

Here is my Gruntfile.js:

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        nodemon: {
            dev: {
                options: {
                    file: 'app.js',
                    nodeArgs: ['--debug'],
                    env: {
                        PORT: '3000'
                    }
                }
            }
        },
        less: {
            development: {
                options: {
                    paths: ['./public/less'],
                    yuicompress: true
                },
                files: {
                    './public/css/test.css': './public/less/test.less'
                }
            }
        },
        watch: {
            files: "./public/less/*.less",
            tasks: ['less']
        }
    });


    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-nodemon');

    grunt.registerTask('default', ['less','watch']);
};
Was it helpful?

Solution

What you're looking for is grunt-concurrent, a task that allows you to run multiple tasks asynchronously and it's incredibly common for blocking tasks such as watch or nodemon.

https://github.com/sindresorhus/grunt-concurrent

As for nodemon, a prime example of this is located directly on the github page for grunt-nodemon using grunt-concurrent under the section 'Advanced Usage'.

https://github.com/ChrisWren/grunt-nodemon#advanced-usage

Hope this is what you're looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top