Visual Studio 2015中的Grunt watch任务绑定

安德鲁·B

问题:我将配置绑定监视任务以始终在Visual Studio 2015中运行时遇到问题。

我的目标:我想监视文件中的更改,一旦更改发生,我想运行一些任务,然后恢复监视任务以查找进一步的更改。

到目前为止我尝试过的是

  1. 我已经在“ ProjectOpened”上为监视任务设置了绑定,但是只有在构建我的项目之前,绑定才起作​​用。构建/重建项目后,监视任务将停止处理跟踪文件的更改。
  2. 我尝试将监视任务绑定到“ 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']);
};

任何帮助将不胜感激。

安德鲁·B

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章