build-if-changed (bic) is a utility designed to optimize monorepo build processes by executing `npm run build` scripts only for packages that have undergone changes since their last build. It achieves this by crawling specified directories within a package, generating SHA-1 hashes of watched files, and storing them in a `.bic_cache` file alongside each `package.json`. If the hashes indicate a change, the build script is triggered. The current stable version is 1.5.5. It focuses on reducing build times and CI/CD costs by avoiding redundant builds, differentiating itself through its simple `package.json`-based configuration and custom glob syntax for file watching.
npm install build-if-changedNo compatibility data collected yet for this library.
This quickstart installs `build-if-changed`, creates a dummy `package.json` with a build script, runs `bic` initially, then simulates a file change to demonstrate how `bic` triggers a build only when necessary.
Consult the `recrawl` package documentation (e.g., `https://www.npmjs.com/package/recrawl#pattern-syntax`) to correctly define file watch patterns in your `package.json` `bic` field.
Structure your `bic` configuration with `skip` patterns as overriding exclusions. Ensure files you intend to watch are not inadvertently included in `skip`.
Plan your file watching configurations knowing that version control and dependency directories are inherently ignored by `build-if-changed`.
Ensure your `build` script does not contain 'bic' or 'build-if-changed' as substrings if you intend for `build-if-changed` to run it. For example, use `my:build` instead of `bic:build`.
Install `build-if-changed` as a dev dependency (`npm install build-if-changed -D` or `yarn add build-if-changed -D`) and then run it using `npx build-if-changed` (for npm) or `yarn build-if-changed` (for yarn).
Add a `"build": "your-build-command-here"` entry to the `scripts` section of the `package.json` for each package that `build-if-changed` should process.
Carefully review the `bic` field in your `package.json`. Verify the custom glob patterns against the `recrawl` documentation and ensure the `skip` array does not inadvertently exclude desired files.
No dependency data recorded yet.