我有一个非常简单的呼叫声设置。唯一活跃的插件是grunt-contrib-connect。这是我的package.json文件:
{
"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看起来像这样:
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不能。以下是控制台的输出:
$ 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
发布于 2013-04-25 02:09:23
配置任务+目标是使其可从命令行使用的重要部分。要创建grunt connect work,请向.initConfig添加配置
grunt.initConfig
connect:
server:
options:
base: 'app'
keepalive: truehttps://stackoverflow.com/questions/16197858
复制相似问题