⛏️ Build hooks+v1.0
Build hooks allow you to observe events that happen during the Hydrogen build process. You can intercept and modify the context of the build process to your liking.
Here are the events you can observe:
-
beforeDistRemoved
-
afterDistRemoved
-
beforeBuild
-
afterBuild
-
beforeEachPageGenerated
-
afterEachPageGenerated
-
beforeEachPageSaved
-
beforeServiceWorkerGenerated
-
afterServiceWorkerGenerated
Basic Setup
Create a file called hydrogen.hooks.js
in the root of your project
All you have to do is export the hooks of the events you want to observe in Hydrogen and that's all there is too it,
keep in mind that the ctx
of the hooks differ.
exports.beforeDistRemoved = async (ctx) => {};
exports.afterDistRemoved = async (ctx) => {};
exports.beforeBuild = async (ctx) => {};
exports.afterBuild = async (ctx) => {};
exports.beforeEachPageGenerated = async (ctx) => {};
exports.afterEachPageGenerated = async (ctx) => {};
exports.beforeEachPageSaved = async (ctx) => {};
exports.beforeServiceWorkerGenerated = async (ctx) => {};
exports.afterServiceWorkerGenerated = async (ctx) => {};