This is an example of a Bazel-based web application made for talk "How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team's Experience"
# install dependencies needed for Bazel
yarn install --production
# run a webapp
yarn ibazel run //packages/webapp:serve
# open https://localhost:8080
WORKSPACE.bazel
represents the Bazel project and specifies the Bazel version, npm dependencies, and general configuration. The common practice is to use "@npm" namespace for all npm dependencies; namespace is defined byyarn_install(name = "npm")
in WORKSPACE.bazel file.bazerc
contains cli bazel config. Here you may define a custom group of configurations for CI, build so on. You can find "debug" config here that enabled verbose more for CLI commands - add--config=debug
for any cmdpackages/
- the dir with internal packagespackages/utils
is a simple utility package built with typescriptpackages/webapp
is a site built with webpacktools/
contains common bazel macros for jest, tsc and webpack builds
yarn bazel build //packages/webapp
- buildyarn ibazel run //packages/webapp:serve
to run in incremental mode with a local dev server. The site is available at http://localhost:8080yarn bazel test //packages/webapp:test
- tests
yarn bazel build //packages/utils
- buildyarn ibazel build //packages/utils
- incremental buildyarn bazel test //packages/utils:test
- tests
yarn bazel build //...
- Build everythingyarn bazel test //...
- Test everything
By default Bazel build everytings in own "root", build outputs are placed under ./bazel-out/darwin-fastbuild/bin/packages/utils
(macOS) or ./bazel-out/k8-fastbuild/bin/packages/utils
(linux).
Also, you may build any package in a debug more to inspect the sandbox yarn bazel build //packages/utils --sandbox_debug
.