heroku - npm postinstall脚本根据enviro运行咕噜任务 [英] heroku -- npm postinstall script to run grunt task depending on enviro

查看:107
本文介绍了heroku - npm postinstall脚本根据enviro运行咕噜任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个heroku node.js应用程序,一个用于prod和一个用于开发,另外我还有一个Gruntfile,其中包含dev和prod特定的任务。我知道你可以设置package.json来运行grunt作为npm的postinstall挂钩,但是你可以指定不同的任务来运行,具体取决于你在哪个环境中运行?



 scripts:{
postinstall:./node_modules/grunt/bin/grunt default
},

不是每次运行grunt默认值,如果NODE_ENV是生产等,我很乐意运行grunt production。



这可能吗?

解决方案

出于某种原因,我的开发环境从未运行我的开发if语句。我给Heroku支持发了一张票,这是他们的回答:默认情况下,你的环境在slug编译期间是不可用的。如果你想使它可用,你可以启用一个名为user-env-compile 。详情请参阅以下文章:
http:// devcenter。 heroku.com/articles/labs-user-env-compile 。很高兴知道。所以,我使用heroku-buildpack-nodejs-grunt buildpack去了另一条路线,然后创建了一个heroku:development grunt任务。


I've got two heroku node.js apps, one for prod and one for dev, and I also have a Gruntfile with dev- and prod-specific tasks. I know you can set up package.json to run grunt as a postinstall hook for npm, but can you specify somehow different tasks to be run depending on what enviro you're in?

Here's what the relevant section of my package.json looks like so far:

"scripts": {
    "postinstall": "./node_modules/grunt/bin/grunt default"
},

Rather than run grunt default every time, I'd love to run "grunt production" if NODE_ENV is production, etc.

Is this possible?

解决方案

For some reason, my dev environment was never running my "development" if statement. I sent a ticket to Heroku support, and this was their answer: "By default, your environment is not available during slug compilation. If you would like to make this available, you can enable an experimental feature called "user-env-compile". Please see the following article for details: http://devcenter.heroku.com/articles/labs-user-env-compile". Good to know. So, I went another route using the heroku-buildpack-nodejs-grunt buildpack, and then creating a heroku:development grunt task.

这篇关于heroku - npm postinstall脚本根据enviro运行咕噜任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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