sailsjs生成动态视图/ ejs文件 [英] sailsjs generate dynamic views/ejs files
问题描述
我正在动态生成/复制ejs文件,并将它们放在views文件夹中,它们在开发模式下可以正常工作,但是在生产模式下,直到我重新启动后,它才反映出更改。我怎样才能使其在生产模式下工作?
I'm generating/copying ejs files dynamically and put them in views folder and they work fine in development mode however in production mode it's not reflecting changes until I relaunch sails. How can I make it work in production mode as well?
我正在使用简单的fs创建/更新文件操作来写入ejs文件
I'm using simple fs create/update file operations to write to ejs file
推荐答案
找到了解决方案。以下帖子对我有帮助:
Found the solution. Following posts helped me in that:
https://github.com/balderdashy/sails/issues/3513
http://expressjs.com/en/api.html
原因就是说,express在生产模式下兑现了视图,因此禁用了它。
The reason is, express was cashing views in production mode, so on disabling that it worked.
sails.hooks.http.app.disable('view cache');
console.log("view-cache-disabled: " + sails.hooks.http.app.disabled("view cache"));
这篇关于sailsjs生成动态视图/ ejs文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!