/protobuf-json-webpack-plugin

protobuf compile to json file

Primary LanguageJavaScript

protobuf-json-webpack-plugin

protobuf compile to json file

install

  npm install protobuf-json-webpack-plugin --save-dev

webpack config

const Proto2JsonPlugin = require('protobuf-json-webpack-plugin')


plugins: [
  new Proto2JsonPlugin(
    inputs: ['/a/b/c.proto', '/a/c/*.proto'],
    output: '/a/b/c/xxxx.js'
  )
]

js call

const struct = require('${output js file path}')
const yyyy = struct.lookupType('xxx.Yyyy')
const jsData = yyyy.decode(data)