How to run two grunt watch tasks simultaneously

前端 未结 9 1042
情歌与酒
情歌与酒 2020-12-12 16:29

Is it possible to run two watch tasks simultaneously?

I understand that I can have any number of tasks I want inside watch settings and just launch grun

9条回答
  •  失恋的感觉
    2020-12-12 16:39

    SEPTEMBER 2018

    You don't need to use grunt-concurrent anymore grunt now has this built in, here is a sample from one of my current projects...

    module.exports = function(grunt) {
        grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            sass: {
                theme: {
                    files: {
                        '../../web/sites/all/themes/ifafri/css/generated/theme_ifafri_master.css' : '../../web/sites/all/themes/ifafri/css/master.scss'
                    }
                },
                bootstrap: {
                    files: {
                        '../../web/sites/all/themes/ifafri/css/generated/theme_ifafri_bootstrap.css' : '../../web/sites/all/themes/ifafri/css/bootstrap/master.scss' 
                    }
                }
            },
            watch: {
                theme: {
                    files: '../../web/sites/all/themes/ifafri/css/*.scss',
                    tasks: ['sass:theme'],
                    options: {
                        spawn: false,
                        livereload: true,
                        nospawn: false
                    }
                },
                bootstrap: {
                    files: '../../web/sites/all/themes/ifafri/css/bootstrap/*.scss',
                    tasks: ['sass:bootstrap'],
                    options: {
                        spawn: false,
                        livereload: true,
                        nospawn: false
                    }
                }
        }
        });
        grunt.loadNpmTasks('grunt-contrib-sass');
        grunt.loadNpmTasks('grunt-contrib-watch');
        grunt.loadNpmTasks('grunt-livereload');
        grunt.registerTask('default',['watch']);
    }
    

提交回复
热议问题