Install Husky from https://typicode.github.io/husky/get-started.html
yarn add --dev husky
# Add pinst ONLY if your package is not private
yarn add --dev pinst
In the wp-content/themes/your-theme/.husky
folder add a file called pre-commit
. Inside pre-commit type:
# .husky/pre-commit
cd wp-content/themes/canadian-centre-recovery-excellence
yarn build
git add public
# To test a hook, add exit 1 to the hook script to abort the Git command
# exit 1
In the package.json add the line under "scripts":
"postinstall": "cd ../../../ && husky wp-content/themes/your-theme/.husky"
Now when you commit, yarn build
should run.