{"id":29228888,"url":"https://github.com/pengzhanbo/protobufjs-webpack-plugin","last_synced_at":"2025-07-03T11:02:15.847Z","repository":{"id":38811236,"uuid":"123404197","full_name":"pengzhanbo/protobufjs-webpack-plugin","owner":"pengzhanbo","description":"protobuf to js","archived":true,"fork":false,"pushed_at":"2022-06-06T19:02:01.000Z","size":11,"stargazers_count":6,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T03:32:05.709Z","etag":null,"topics":["protobuf","protobufjs","protobufjs-webpack-plugin","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pengzhanbo.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-01T08:19:13.000Z","updated_at":"2023-01-27T20:11:23.000Z","dependencies_parsed_at":"2022-08-30T05:05:24.869Z","dependency_job_id":null,"html_url":"https://github.com/pengzhanbo/protobufjs-webpack-plugin","commit_stats":null,"previous_names":["volodymyr-lian/protobufjs-webpack-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pengzhanbo/protobufjs-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengzhanbo%2Fprotobufjs-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengzhanbo%2Fprotobufjs-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengzhanbo%2Fprotobufjs-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengzhanbo%2Fprotobufjs-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pengzhanbo","download_url":"https://codeload.github.com/pengzhanbo/protobufjs-webpack-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengzhanbo%2Fprotobufjs-webpack-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263314092,"owners_count":23447289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["protobuf","protobufjs","protobufjs-webpack-plugin","webpack","webpack-plugin"],"created_at":"2025-07-03T11:02:07.918Z","updated_at":"2025-07-03T11:02:15.825Z","avatar_url":"https://github.com/pengzhanbo.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# protobufjs-webpack-plugin\n\n转译protobuf文件为js文件\n\n### Install\n\n``` bash\nnpm install --save-dev protobufjs-webpack-plugin\n```\n\n### Usage\n\nAdd it to your `webpack.config.js`\n``` js\nvar ProtobufPlugin  = require('protobufjs-webpack-plugin');\n\nmodule.exports = {\n    plugins: [\n        new ProtobufPlugin({\n            input: path.join('proto', '*.proto'),\n            output: path.join('dist', 'proto')\n        })\n    ]\n};\n```\n\n### Config\n``` js\n{\n    input: '',      // 输入文件匹配\n    output: '',     // 输出路径， 如果是文件夹，单文件输出则以 basic.proto.js命名，多文件以文件名拼接\n    outputType: 1,  // 输入方式，默认多文件形式， 如果设置为 0，则所有合并为单文件\n    target: 'static-module',    // 类型 json|json-module|static\\static-module\n    format: 'es6',  // 输出格式： es6|commonjs|amd|closure\n    create: true,   // 是否需要 create方法\n    encode: true,   // 是否需要 encode 方法\n    decode: true,   // 是否需要 decode 方法\n    verify: true,   // 是否需要 verify 方法\n    delimited: true,    // 是否需要 delimited 方法\n    beautify: true,     // 是否需要美化代码\n    comments: true,     // 是否需要代码注释文档\n    convert: true   // 是否需要 from/toObject\n}\n```\n\n### Example\n`demo.proto`\n``` protobuf\npackage base;\nsyntax = \"proto3\";\n\nmessage base {\n    string base = 1;\n}\n```\ncompile to `base.js`\n\nIn your js\n``` js\nvar axios = require('axios');\nvar base = require('base.js');\n\n// decode data\nfunction fetchDecode(proto, data) {\n    return proto.decode(new Uint8Array(data));\n}\n\n// encode data\nfunction fetchEncode(proto, data) {\n    return proto.encode(proto.create(data)).finish();\n}\n\nlet buffer = fetchEncode(base.base, {'base': '1'});\n\naxios.post('http://localhost:8080/protobuf', buffer, {\n    responseType: 'arraybuffer',\n    headers: {\n        'Content-type': 'application/octet-stream'\n    }\n})\n    .then(res =\u003e {\n        let data = fetchDecode(base.base, res);\n        console.log(data);\n    });\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpengzhanbo%2Fprotobufjs-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpengzhanbo%2Fprotobufjs-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpengzhanbo%2Fprotobufjs-webpack-plugin/lists"}