Skip to main content

Paths

Setting application paths

bud.setPath is used to set project source and output paths.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
/* Set the source path. */
bud.setPath('@src', 'source')
/* Set the output path. */
bud.setPath('@dist', 'build')
}

The @src and @dist handles are special handles associated with the input and output base directories.

Referencing application paths

Once set, paths can be referenced using bud.path.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
bud.path('@src') // absolute path to source directory
bud.path('@dist') // absolute path to output directory
}

Globbing

bud.glob can be used to construct a list of files matching a given pattern.

This function is asychronous.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
await bud.glob('@src', '**/*.js') // returns an array of absolute paths
}

There is a synchronous version available as well: bud.globSync.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
bud.globSync('@src', '**/*.js') // returns an array of absolute paths
}