So i have added the following which rebuilds both my backend and frontend as soon as a page has been updated-i.e if a user in the cms updates the blurb section. However, it just seems so wrong to rebuild the whole site based on trivial updates…surely there is a better way of doing this?
‘use strict’;
/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/concepts/models.html#lifecycle-hooks)
* to customize this model
*/
module.exports = {
lifecycles: {
async afterUpdate(result, params, data) {
console.log(result)
const { exec } = require("child_process");
exec("cd ~/stagStrapi/backend && npm run build && cd ~/stagStrapi/frontend && npm run build", (error, stdout, stderr) => {
if(error){
console.log('error', error)
console.log('stderr', stderr)
}
exec("cd ~ && pm2 restart ecosystem.config.js", (errorEco, ecoStdOut, ecoStdErr) => {
if(errorEco){
console.log('error', errorEco)
console.log('stderr', ecoStdErr)
}else{
console.log('ecoStdOut', ecoStdOut)
}
});
console.log('stdout',stdout)
});
},
},
}