0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Protocol Buffersで.protoファイルと同じディレクトリに_pb.tsを出力したい

Posted at

protobuf-esを使ってTypeScriptの型定義ファイルを出力する際に、.protoファイルと同じディレクトリに出力させる方法の備忘録

ディレクトリ構造

root
  ├ src
  │ └ features
  │   ├ hoge
  │   │ ├ hoge.proto
  │   │ └ hoge_pb.ts <- ここに作りたい
  │   └ fuga
  │      ├ fuga.proto
  │      └ fuga_pb.ts <- ここにも
  └ buf.gen.yaml

解決策

buf.gen.yamlでinputとoutを同じディレクトリにする

buf.gen.yaml
version: v2
inputs:
  - directory: "./src/features"
plugins:
  - local: protoc-gen-es
    out: "./src/features"
    opt:
      - target=ts

ただし、生成コマンドはrootでpnpm exec buf generate

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?