How to debug a Gulp task?

后端 未结 7 1761
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 01:12

How do I debug a gulp task defined in my gulpfile.js with a debugger such as the Google Chrome debugger, stepping through the task\'s code line by line?

7条回答
  •  再見小時候
    2021-01-30 01:40

    I liked the answer of @Avi Y. but I suppose people would had appreciated a more complete script :

    gulp.task('nodemon', ['sass'], function(cb) {
    var started = false;
        consoleLog('nodemon started');
    return nodemon({
        //HERE REMOVE THE COMMENT AT THE BEGINING OF THE LINE YOU NEED
        //exec: 'node --inspect --debug-brk node_modules/gulp/bin/gulp.js', 
        exec: 'node --inspect --debug-brk',
        //exec: 'node --inspect',
        script: path.server,
        ignore: ['*/gulpfile.js', 'node_modules/*'],
        verbose: true
    }).on('start', function() {
        if (!started) {
            cb();
            started = true;
        }
    }).on('restart', function() {
        consoleLog('nodemon restarted the server');
    });});
    

提交回复
热议问题