Overview of Frontend development with Bazel
mainrules_js, which is based on the pnpm package manager. The folder is structured as a pnpm workspace, enabling monorepo support where npm packages can depend on one another within the repository.repository·main·Indexed 21 days ago
https://github.com/bazelbuild/examplesA collection of practical examples and tutorials for the Bazel build system. Includes demonstrations for various languages (C++, Java, Rust), platforms (Android), and web frameworks (Next.js, React, Vue), as well as detailed guides on using Bzlmod for dependency management, module extensions, and toolchain registration.
rules_js, which is based on the pnpm package manager. The folder is structured as a pnpm workspace, enabling monorepo support where npm packages can depend on one another within the repository.This example demonstrates how to transpile and bundle a React JS application using Bazel. The build process is split into two distinct stages:
rules_swc, this stage converts JSX files into plain JavaScript files.rules_webpack, this stage takes the plain JS files and bundles them into a single JS file. It also utilizes an HTML template plugin (configured within the Webpack rule) to generate an entry point for the browser.Note that there are two Webpack configurations present:
webpack.bazel.config.js: The specific configuration used by Bazel.webpack.config.js: A sample configuration used to demonstrate the differences between a standard Webpack setup and a Bazel-integrated setup.This package provides various examples for building Rust code using Bazel. It covers common use cases such as cross-compilation, compiler optimization, FFI (Foreign Function Interface), dependency management (Cargo workspaces, direct Bazel dependencies, and vendoring), gRPC client/server implementation, and OCI container image creation.
Platform Support:
This directory provides a collection of examples for extending Bazel by writing custom rules. The examples are categorized into basic rule features and advanced scenarios to help you understand how to manipulate actions, manage dependencies, and handle outputs.
Use these examples to learn the fundamentals of rule implementation:
empty/ shows the absolute minimum required to define a rule.attributes/ demonstrates how to define and use rule attributes.actions.run: Using a binary target as an implicit dependency and executing it.actions.write: Generating a file directly.expand_template: Generating files based on a template.shell command: Executing shell commands for text processing.mandatory provider: Accessing information from a dependency via a mandatory provider.optional provider: Accessing information from a dependency via an optional provider.depsets: Using depset to gather transitive information from dependencies.Use these examples for more complex control over rule behavior:
executable/ for executable rules, test rule/ for test rules, and runfiles/ for rules requiring specific files at runtime.computed dependencies/ where implicit dependencies are determined by rule attributes.predeclared outputs: Using attr.output_list and outputs.implicit output: Handling outputs that are only available when explicitly requested.aspect/ demonstrates how to use an aspect to collect information from other rules in the dependency graph.res/values/values.xml resource file. You can use the tools_android repository to automate the generation of this values.xml file from the google-services.json file downloaded from your Firebase console.This repository contains progressive examples for learning how to build C++ code using Bazel. The tutorial is structured into three stages of increasing complexity, moving from single-file compilation to multi-package library linking.
For the full tutorial context, visit the official Bazel documentation at https://bazel.build/start/cpp.
The repository is organized into specialized cookbooks for different technologies. You can find specific implementation patterns for:
genrule-specific variables, and custom variables defined via Starlark.The Android NDK example is structured into three main layers of Bazel targets:
cc_library target located at //app/src/main:jni_lib.android_library target at //app/src/main:lib. This target has a dependency on the //app/src/main:jni_lib target.android_binary target at //app/src/main:app, which depends on the //app/src/main:lib target.Note: The build graph for this example omits Google Maven AAR dependencies.