gRPC gen
Simple command line for running the protoc compiler via a configuration file
Configuration
Example .grpc-gen.yml
config file
srcs_dir: ./src
srcs:
- file.proto
output:
plugin-name: output-directory
Output
The output configuration can either be an array or an object. Each element must be an object with exactly one key. The one key must be the plugin/language name. The value has a long syntax and a short syntax.
Long Syntax
output:
- js:
dir: dist/node
options:
import_style: commonjs
- custom-plugin:
custom: true
plugin: grpc_tools_node_protoc_plugin
dir: dist/node
options:
Short Syntax
output:
- php: dist/php
Install
Install globally
npm i -g grpc-gen
OR install locally in your project as a dev dependency and add a build script to your package.json
.
npm i -D grpc-gen
"scripts": {
"build": "grpc-gen"
},
"devDependencies": [
"grpc-gen": "^1.0.2"
]
npm run build
Usage
Running grpc-gen
in the directory containing your configuration file will build your proto files.
grpc-gen
You can also specify a different configuration file with --config
grpc-gen --config=custom-config.yml
grpc-gen
may also run in watch mode. When your config file or proto files change compilation will re-run.
grpc-gen --watch
Troubleshooting
If grpc-gen is not behaving the way you expect and want to dive into the issue you can run grpc-gen
in verbose mode. Just pass --verbose
or -v
.
grpc-gen --verbose