bufbuild / buf

The best way of working with Protocol Buffers.
https://buf.build
Apache License 2.0
9.04k stars 273 forks source link

Use Buf with --plugin from node_module #979

Closed g3david405 closed 2 years ago

g3david405 commented 2 years ago

I am now generating javascript grpc code. Example is as following: protoc --grpc_out=./ --plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin -I ./proto ./proto/*.proto.
How can I use Buf to do this? Thanks!!

smallsamantha commented 2 years ago

Thanks for the question!! Please check out our docs on replacing protoc with buf https://docs.buf.build/how-to/replace-protoc-with-buf

smallsamantha commented 2 years ago

Also check out the Remote Plugin Execution docs, because this is an ideal use case! You'd end up with a buf.gen.yaml file looking something like:

version: v1
plugins:
  - remote: buf.build/grpc/plugins/node:v1.11.2-1
    out: ./

you'd run this with buf generate proto due to your directory setup, and you'd have your buf.yaml within ./proto

g3david405 commented 2 years ago

@smallsamantha thanks!!!! I love you so much