【问题标题】:vs2013 task runner explorer does not detect gruntjs tasksvs2013 任务运行器资源管理器未检测到 gruntjs 任务
【发布时间】:2015-09-17 22:58:36
【问题描述】:

这是我在 vs2013 网络项目中的 gruntjs 文件中的一个 sn-p。我看到的是在 initconfig 中添加最后一行以加载设置停止显示 VS2013 Task Runner Explorer 中的任务。只要注释掉该行,Task Runner Explorer 就会枚举我的任务。 Task Runner ExplorerI 的输出窗口中没有错误。

我可以使用 grunt cli 很好地运行我的 gruntfile.js。

 grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),
        target: grunt.config.get('target'),
        settings: grunt.file.readJSON('config/' + grunt.option('target') + '.json'), //problematic line
karma: {
            unit: {
                configFile: 'karma.conf.js'
            }
        },

【问题讨论】:

  • 你找到解决这个问题的方法了吗?刷新“任务运行器资源管理器”时,它似乎尝试实际读取JSON,因此您必须将文件放在那里...

标签: visual-studio-2013 gruntjs


【解决方案1】:

我遇到了 grunt.file.readJSON 的问题,我通过给我的选项一个自调用函数来解决它,该函数检查文件是否存在。比如:

settings: function () {
                    if (grunt.file.exists('config/' + grunt.option('target') + '.json')) {
                        return grunt.file.readJSON('config/' + grunt.option('target') + '.json')
                    }
                    return '';
                }()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多