2014-10-17 64 views
0

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

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

+0

你有什么特别的理由想要这样做吗? – CaseyWebb 2014-12-05 18:38:37

+0

我的应用程序允许用户在某种意义上将新页面“上传”到应用程序,因此我需要Grunt在资产移入资产时观察和重新编译资产,否则应用程序需要重新启动以反映新的更改。 – kk415kk 2014-12-05 19:18:10

+0

您是否找到解决方案? – thesearentthedroids 2017-01-17 20:23:44

回答

0

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

最近我发现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(); 
+0

有没有办法解决这个问题,它不涉及编辑node_modules中的文件。我从git拉到我的服务器并运行npm install,node_modules不被git监视。除此之外的任何方式将不胜感激 – 2016-06-24 09:31:17