# webpack-grpc-web-loader

> A webpack loader to load .proto files for grpc-web with effortless setup.

Latest version **0.1.8** (published 2024-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-grpc-web-loader
pnpm add webpack-grpc-web-loader
yarn add webpack-grpc-web-loader
bun add webpack-grpc-web-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2024-07-16 |
| First published | 2019-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | foisonocean |
| Maintainers | foisonocean |

## Links

- npm: https://www.npmjs.com/package/webpack-grpc-web-loader
- Repository: https://github.com/foisonocean/webpack-grpc-web-loader
- Homepage: https://github.com/foisonocean/webpack-grpc-web-loader#readme
- Issues: https://github.com/foisonocean/webpack-grpc-web-loader/issues
- npm.io page: https://npm.io/package/webpack-grpc-web-loader

## Dependencies (8)

- [execa](https://npm.io/package/execa.md) ^1.0.0
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.3
- [rollup](https://npm.io/package/rollup.md) ^1.9.3
- [grpc-tools](https://npm.io/package/grpc-tools.md) ^1.12.4
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.2.3
- [schema-utils](https://npm.io/package/schema-utils.md) ^1.0.0
- [protoc-gen-grpc-web](https://npm.io/package/protoc-gen-grpc-web.md) ^1.5.0
- [rollup-plugin-commonjs](https://npm.io/package/rollup-plugin-commonjs.md) ^9.3.4

## Recent versions

- 0.1.8 (latest) — 2024-07-16
- 0.1.7 — 2024-07-15
- 0.1.6 — 2019-05-14
- 0.1.5 — 2019-05-14
- 0.1.4 — 2019-04-11
- 0.1.3 — 2019-04-10
- 0.1.2 — 2019-03-15
- 0.1.1 — 2019-03-13
- 0.1.0 — 2019-03-12

## README

# Webpack GRPC Web Loader

## Install

👉 You don't have to install protoc or [protoc-gen-grpc-web](https://github.com/grpc/grpc-web/releases) plugin in your environment, just use npm or yarn to install this webpack loader, and everything is done.

```sh
npm install --save-dev webpack-grpc-web-loader
```

Or

```sh
yarn add --dev webpack-grpc-web-loader
```

## Getting Started

### webpack.config.js

```javascript
const path = require('path');

module.exports = {
  module: {
    rules: [
      {
        test: /\.proto$/,
        use: [
          {
            loader: 'webpack-grpc-web-loader',
            options: {
              protoPath: path.resolve(__dirname, './src/protos'),
            },
          },
        ],
      },
    ],
  },
};
```

If you have multiple proto paths, you can pass an array to the option `protoPath`:

```javascript
{
  loader: 'webpack-grpc-web-loader',
  options: {
    protoPath: [
      path.resolve(__dirname, './src/my-protos-1'),
      path.resolve(__dirname, './src/my-protos-2'),
    ],
  },
}
```

### In your src

```javascript
import helloWorldProto from './hello-world.proto';

const client = new helloWorldProto.HelloWorldClient('http://localhost:11101/grpc');
const helloRequest = new helloWorldProto.HelloRequest();
client.helloWorld(helloRequest, {}, (err, res) => {
  // handle error and response here
});
```

## Options

| Option Name |        Type        | Required | Default Value |               Description               |
|-------------|:------------------:|:--------:|:-------------:|:---------------------------------------:|
| protoPath   | string \| string[] |   true   |      N/A      | Same as `--proto_path` (`-I`) in protoc |

---
_Source: https://npm.io/package/webpack-grpc-web-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
