Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@
Converts .proto files into JSON so they can be [loaded without a parser](https://github.com/dcodeIO/ProtoBuf.js/wiki/Builder#using-json-without-the-proto-parser). For use with [webpack](http://webpack.github.io/docs/) and [ProtoBuf.js](https://github.com/dcodeIO/ProtoBuf.js)

## Installation
npm install proto-loader
```sh
npm install proto-loader --save-dev
```

## Usage

[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)

``` javascript
```js
/*
protobufjs has a light build that does not include code for parsing .proto
files. The extra code is not typically necessary if you're using this loader,
but if you still need it, you can change the below line to:
var ProtoBuf = require('protobufjs');
*/
var ProtoBuf = require('protobufjs/dist/protobuf-light');
const ProtoBuf = require('protobufjs/dist/protobuf-light');

var protoDefinition = require('proto!./message.proto');
const protoDefinition = require('proto!./message.proto');
// => returns object converted from message.proto, resolves imports

var builder = ProtoBuf.loadJson(protoDefinition);
const builder = ProtoBuf.loadJson(protoDefinition);
//...
```

### webpack config

``` javascript
```js
module.exports = {
module: {
loaders: [
Expand Down