Skip to main content


Executes a function if a given test is true.

  • The first parameter is the conditional check.
  • The second parameter is the function to run if true.
  • The third parameter is optional; executed if the conditional is not true.


Only produce a vendor bundle when running in production mode:

bud.when(bud.isProduction, () => bud.vendor())

Use eval sourcemap in development mode and hidden-source-map in production:

() => bud.devtool('eval'),
() => bud.devtool('hidden-source-map'),

For clarity, here is a very verbose version of the same thing:

const test = bud.isDevelopment
const inProduction = () => bud.devtool('eval')
const inDevelopment = () => bud.devtool('hidden-source-map')

bud.when(test, inProduction, inDevelopment)