UNPKG

@roots/bud-api

Version:

bud.js core module

44 lines (43 loc) 659 B
/** * Enables lazy compilation of built assets. * * @example * Enable: * * ```js * bud.lazy() * ``` * * @example * Explicitly disable: * * ```js * bud.lazy(false) * ``` * * @example * Explicitly enable: * * ```js * bud.lazy(true) * ``` * * @example * Use with object options: * * ```js * bud.lazy({ * entries: false, * imports: true, * }) * ``` */ export const lazy = function (value = true) { this.hooks.on(`build.experiments`, experiments => { if (!experiments) { return { lazyCompilation: value }; } return { ...experiments, lazyCompilation: value }; }); return this; };