Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-grpc-web-loader

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-grpc-web-loader

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

  • 0.1.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31
increased by106.67%
Maintainers
0
Weekly downloads
 
Created
Source

Webpack GRPC Web Loader

Install

👉 You don't have to install protoc or protoc-gen-grpc-web plugin in your environment, just use npm or yarn to install this webpack loader, and everything is done.

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

Or

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

Getting Started

webpack.config.js

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:

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

In your src

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 NameTypeRequiredDefault ValueDescription
protoPathstring | string[]trueN/ASame as --proto_path (-I) in protoc

FAQs

Package last updated on 16 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc