简体   繁体   English

Visual Studio 2015中的Grunt监视任务绑定

[英]Grunt watch task binding in Visual Studio 2015

Problem : I have a problem to configure binding for grunt watch task to always run in Visual Studio 2015. 问题 :我有一个问题是为grunt watch任务配置绑定以始终在Visual Studio 2015中运行。

My goal : I want to watch files for changes and once the change occurs I want to run some task and then resume watch task to look for further changes. 我的目标 :我想观察文件的变化,一旦发生变化,我想运行一些任务,然后恢复观察任务以寻找进一步的变化。

What I have tried so far : 到目前为止我尝试了什么

  1. I have set binding for watch task on 'ProjectOpened', but it only does work then until I build my project. 我已经在'ProjectOpened'上为watch任务设置了绑定,但它只能在我构建项目之前工作。 Once I build/rebuild my project the watch task stops handling the changes of tracked files. 一旦我构建/重建我的项目,监视任务就会停止处理跟踪文件的更改。
  2. I have tried binding my watch task to 'AfterBuild' and 'BeforeBuild', but having that set, the build operation hangs forever in Visual Studio (it just never ends). 我已经尝试将我的监视任务绑定到'AfterBuild'和'BeforeBuild',但是有了这个设置,构建操作在Visual Studio中永远挂起(它永远不会结束)。

Here's my gruntfile.js: 这是我的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']);
};

Any help will be appreciated. 任何帮助将不胜感激。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM