Cordova建筑钩+ Grunt [英] Cordova Build Hooks + Grunt

查看:199
本文介绍了Cordova建筑钩+ Grunt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图链接我的cordova版本与grunt,我们运行的任务在本地服务项目,我想在我们的Cordova构建期间重用。为此,我创建一个简单的before_build钩子并将其放置在hooks / before_build中。

I am trying to link-up my cordova build with grunt, there are a tasks that we run when serving the project locally that I would like to reuse during our Cordova build. For this I create a simple before_build hook and placed it in hooks/before_build.

我的构建钩子如下:

#!/usr/bin/env node
var grunt = require('grunt');
grunt.tasks(['build']);
process.exit(0);

构建的初始部分效果良好,所有文件都按预期复制。但是,在我的 build 任务中,我会进行几个额外的调用,如:

The initial part of the build works well, all of the files are copied as expected. However, within my build task, I make several additional calls such as:

grunt.task.run('wiredep');

这和所有其他类似的调用,无法执行,没有错误或警告。

This, and all other similar calls, fail to execute without an error or warning.

为什么我无法调用其他grunt任务?

在Gruntfile中使用 loadNpmTask registerTask 定义的,这是不正确的配置吗?

All of my tasks are defined in the Gruntfile using either loadNpmTask or registerTask, is this an incorrect configuration?

推荐答案

我收到了一些关于Grunt问题板的反馈:

https://github.com/gruntjs/grunt/issues/1265

I received some feedback on the Grunt issues board:
https://github.com/gruntjs/grunt/issues/1265

我需要调用我的一个Grunt任务,我添加一个带有以下内容的hook_task.sh文件:

Any time I need to call one of my Grunt tasks, I add a hook_task.sh file with the following:

#!/bin/sh
grunt build

适用于Windows / Linux / Mac 问题。

我仍然想知道为什么节点方法不工作。我觉得我的一部分感觉更舒适使用这种方法,但这是工作很好所以没有投诉。

I would still like to know why the node approach was not working. Part of me feels much more comfortable using that approach, but this is working well so no complaints.

(注意:我的Gruntfile.js是在我的Cordova应用程序的根)

(Note: My Gruntfile.js is in the root of my Cordova App)

这篇关于Cordova建筑钩+ Grunt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆