首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么grunt-contrib-connect找不到connect任务?

为什么grunt-contrib-connect找不到connect任务?
EN

Stack Overflow用户
提问于 2013-04-25 00:56:15
回答 1查看 4.9K关注 0票数 3

我有一个非常简单的呼叫声设置。唯一活跃的插件是grunt-contrib-connect。这是我的package.json文件:

代码语言:javascript
复制
{
  "name": "gruntApp",
  "version": "0.1.0",
  "description": "An application for testing Grunt.js",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-connect": "~0.3.0"
  }
}

我的gruntfile看起来像这样:

代码语言:javascript
复制
module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON 'package.json'
    log:
      start: 'Grunt is starting for application <%=pkg.name%> v<%=pkg.version%>'
      end: 'Grunt is finishing'
  grunt.registerMultiTask 'log', ->
    grunt.log.writeln this.data
  grunt.registerTask 'printConfig', ->
    grunt.log.writeln JSON.stringify grunt.config(), null, 2
  grunt.loadNpmTasks 'grunt-contrib-connect'
  grunt.registerTask 'default', [
    'log:start'
    'log:end'
  ]

我的自定义任务可以工作,但grunt connect不能。以下是控制台的输出:

代码语言:javascript
复制
$ grunt connect -v

Initializing
Command-line options: --verbose

Reading "Gruntfile.coffee" Gruntfile...OK

Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK

Registering "grunt-contrib-connect" local Npm module tasks.
Reading /Users/eric/Projects/gruntApp/node_modules/grunt-contrib-connect/package.json...OK
Parsing /Users/eric/Projects/gruntApp/node_modules/grunt-contrib-connect/package.json...OK
Loading "connect.js" tasks...OK
+ connect
Loading "Gruntfile.coffee" tasks...OK
+ default, log, printConfig

Running tasks: connect

Running "connect" task
>> No "connect" targets found.
Warning: Task "connect" failed. Use --force to continue.

Aborted due to warnings.

怎么回事,你?它看起来像是检测到了连接任务,但后来却找不到目标。我遗漏了什么?我是按照这里的指示来做的:https://github.com/gruntjs/grunt-contrib-connect#getting-started

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-25 02:09:23

配置任务+目标是使其可从命令行使用的重要部分。要创建grunt connect work,请向.initConfig添加配置

代码语言:javascript
复制
grunt.initConfig
  connect:
    server:
      options:
        base: 'app'
        keepalive: true
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16197858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档