The recommended way to generate code is using the buf CLI.
- Create a
buf.gen.yaml configuration file in your project root:
version: v2
plugins:
# Invokes protoc-gen-es to generate base types
- local: protoc-gen-es
out: src/gen
opt: target=ts
# Invokes protoc-gen-connect-query to generate Connect-Query clients
- local: protoc-gen-connect-query
out: src/gen
opt: target=ts
- Run the generation command:
npx @bufbuild/buf generate
You can also add this to your package.json scripts for easier access:
"scripts": {
"buf:generate": "buf generate"
}
version: v2
plugins:
- local: protoc-gen-es
out: src/gen
opt: target=ts
- local: protoc-gen-connect-query
out: src/gen
opt: target=ts