Pawan Jasoria
Pawan Jasoria

Reputation: 191

How to run two different Grunt task in one command?

I am using 'cssmin' and 'sass' grunt task separately, Is it possible to run them one after other automatically, when I can anything in my file.

cssmin: {
        target: {
            files: [{
                    cwd: srcCss,
                    src: ['**/*.css', '*.css'],
                    dest: buildCss
                }]
        }
    },
    sass: {
        target: {
            files: [{
                    cwd: srcScss,
                    src: ['**/*.scss', '*.scss'],
                    dest: srcCss
                }]
        }
    }

Upvotes: 1

Views: 32

Answers (1)

Shobhit Verma
Shobhit Verma

Reputation: 834

This can be done easily: You need to use watch plugin,

  1. npm install grunt-contrib-watch
  2. grunt.loadNpmTasks('grunt-contrib-watch');

3.

grunt.initConfig({

  watch: {

    scripts: {
      files: ['lib/*.js'],
      tasks: ['jshint'],
      options: {
        spawn: false,
      },
    },
    },

    jshint: {

    all: {
      src: ['lib/*.js'],
    },


    },

    });

// Default task(s).

grunt.registerTask('default', 'watch');
  1. Now Just run grunt in cmd.

Upvotes: 1

Related Questions