Paths
Setting application paths
bud.setPath is used to set project source and output paths.
- TS
- JS
- YML
- JSON
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')
}
bud.config.js
/** @param {import('@roots/bud').Bud} bud */
export default async (bud) => {
/* Set the source path. */
bud.setPath('@src', 'source')
/* Set the output path. */
bud.setPath('@dist', 'build')
}
bud.config.yml
setPath:
- '@src'
- 'source'
bud.config.json
{
"setPath": ["@src", "source"]
}
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.
- TS
- JS
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
}
bud.config.js
/** @param {import('@roots/bud').Bud} bud */
export default async (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.
- TS
- JS
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
}
bud.config.js
/** @param {import('@roots/bud').Bud} bud */
export default async (bud) => {
await bud.glob('@src', '**/*.js') // returns an array of absolute paths
}
There is a synchronous version available as well: bud.globSync.
- TS
- JS
bud.config.ts
import type {Bud} from '@roots/bud'
export default async (bud: Bud) => {
bud.globSync('@src', '**/*.js') // returns an array of absolute paths
}
bud.config.js
/** @param {import('@roots/bud').Bud} bud */
export default async (bud) => {
bud.globSync('@src', '**/*.js') // returns an array of absolute paths
}