在Visual Studio 2015中绑定Grunt watch任务

3

问题:我有一个问题,就是如何配置grunt watch任务,让其在Visual Studio 2015中持续运行。

我的目标:我希望能够监视文件的变化,一旦发生变化,就可以运行一些任务,然后继续监视以寻找进一步的变化。

到目前为止我尝试过的

  1. 我已经在'ProjectOpened'上设置了watch任务的绑定,但它只在构建项目之前起作用。一旦我构建/重新构建项目,watch任务就停止处理已跟踪文件的更改。
  2. 我尝试将我的watch任务绑定到'AfterBuild'和'BeforeBuild',但是在设置这些后,在Visual Studio中构建操作会永远挂起(它永远不会结束)。

以下是我的gruntfile.js:

/// <binding AfterBuild='default' ProjectOpened='watch' />

module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');

grunt.initConfig({
    bower: {
        install: {
            options: {
                targetDir: 'wwwroot/vendor',
                layout: 'byComponent',
                install: true,
                cleanTargetDir: true,
            }
        }
    },
    less: {
        development: {
            files: { 'wwwroot/navbar.css': 'LessStyleSheets/navbar.less' }
        }
    },
    watch: {
        options: {
            interrupt: true
        },
        files: ['LessStyleSheets/navbar.less'],
        tasks: ['less']
    }
});

grunt.registerTask('default', ['bower:install', 'less']);
};

非常感谢您的帮助。

1个回答

1
显然,问题已经解决了... 重启Visual Studio后,问题消失了,构建过程在运行grunt watch任务后不再挂起。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接