sailsjs generate dynamic views/ejs files

白昼怎懂夜的黑 提交于 2019-12-12 02:16:36

问题


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?

I'm using simple fs create/update file operations to write to ejs file


回答1:


Found the solution. Following posts helped me in that:

Sailsjs view caching (bug ?)

https://github.com/balderdashy/sails/issues/3513

http://expressjs.com/en/api.html

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"));



回答2:


You have to use a watcher like forever, nodemon, or something else...

Install forever by running:

sudo npm install -g forever

Run it:

forever -w start app.js


来源:https://stackoverflow.com/questions/36204210/sailsjs-generate-dynamic-views-ejs-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!