【问题标题】:In Grunt, no targets found在 Grunt 中,没有找到目标
【发布时间】:2013-09-05 11:11:15
【问题描述】:

我正在尝试使用 Grunt 和 coffeescript 中的所有源代码构建一个项目。首先,我想通过 coffeelint 运行所有源代码。我的 Gruntfile.coffee 是:

#  Gruntfile for base code for Polyglot

module.exports = ->
  @initConfig

  @loadNpmTasks 'grunt-coffeelint'

  coffeelint:
    all:["*.coffee"]

  @registerTask "default",["coffeelint"]

我愿意:

咕哝

然后得到:

未找到“coffeelint”目标。

我期待 lint Gruntfile.coffee。

我做错了什么?

【问题讨论】:

    标签: coffeescript gruntjs


    【解决方案1】:

    Gruntfile 应该有一个带有参数的函数:

    module.exports = (grunt)->
      grunt.initConfig
    
      grunt.loadNpmTasks 'grunt-coffeelint'
    
      coffeelint:
        all:["*.coffee"]
    
      grunt.registerTask "default",["coffeelint"]
    

    编辑:coffeelint 的任务配置也应该嵌套在initConfig 中,并且coffeelint 不会将all 作为其配置的一部分。也许你的意思是app?:

    module.exports = (grunt)->
      grunt.initConfig
        coffeelint:
          app:["*.coffee"]
    
      grunt.loadNpmTasks 'grunt-coffeelint'
      grunt.registerTask "default",["coffeelint"]
    

    【讨论】:

    • 如果您的 Gruntfile 太长,请注意再次出现 grunt.initConfig。它可能会覆盖设置...
    猜你喜欢
    • 2012-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 2017-09-06
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多