【问题标题】:Sails.js: Running grunt watch task in productionSails.js:在生产中运行 grunt watch 任务
【发布时间】:2014-10-17 22:23:11
【问题描述】:

我想在生产模式下运行与在开发模式下运行的完全相同的 grunt watch 任务。我认为这就像将监视任务添加到tasks/register/prod.js 中的“prod.js”任务一样简单,但是这样做会使 Sails 在提升时挂起。

如何在生产环境中运行监视任务?

【问题讨论】:

  • 您有什么特别的理由要这样做吗?
  • 我的应用程序允许用户,在某种意义上,“上传”新页面到应用程序,所以我需要 Grunt 观察和重新编译资产,因为它们被移动到资产中,否则应用程序将需要重新启动以反映新的变化。
  • 你找到解决办法了吗?

标签: node.js gruntjs sails.js grunt-contrib-watch


【解决方案1】:

如何在生产中运行监视任务?

我最近发现,sails (v.0.11.0) 在启动前限制了生产模式下的 grunt 执行。要解决这个问题,您需要在 /node_modules/sails/lib/hooks/grunt/index.js 中更改几行

具体来说,注释以下行:

// Fire finish after grunt is done in production
/*if(sails.config.environment === 'production'){
  cb_afterTaskStarted();
}*/

评论并添加:

// Go ahead and get out of here, since Grunt might sit there backgrounded
/*if(sails.config.environment !== 'production'){
 cb_afterTaskStarted();
}*/
cb_afterTaskStarted();

【讨论】:

  • 有没有办法解决这个问题,而不涉及编辑 node_modules 中的文件。我从 git 拉到我的服务器并运行 npm install,git 不监视 node_modules。除此以外的任何方式都将不胜感激
猜你喜欢
  • 2015-06-04
  • 1970-01-01
  • 2013-05-25
  • 2015-12-29
  • 1970-01-01
  • 2017-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多