This project provides an extension to Bazel to compile Google Closure Templates files into JavaScript files.
This extension is used in existing BUILD files in your project. For directories
that contain .soy
files, add the following rule:
load("//path/to/closure_templates", "soy_library")
soy_library(
name = 'my_soy_library',
srcs = glob(["*.soy"]),
)
In a terminal, then run the command:
bazel build //path/to/src:my_soy_library
This will generate a .soy.js
file for every Soy source file in that directory.
- Set up Bazel by following the instructions on the Getting Started page
- Put a copy of the SoyToJsSrcCompiler.jar in a tools/ directory in your project.
- Put the closure_templates.bzl file somewhere in your project. Every BUILD file that uses Soy will need to load this .bzl file at that path.
- Follow Usage instructions.
To test out this extension using this project, follow these instructions:
- Run
git clone https://github.com/mknichel/closure-templates-bazel.git
- Set up Bazel by following the instructions on the Getting Started page
- Run
bazel build //demo:demo_soy
- Examine the output in bazel-genfiles/demo/demo.soy.js