npm.io
1.0.0 • Published 3 years ago

vite-plugin-proto

Licence
GPL-3.0
Version
1.0.0
Deps
1
Size
39 kB
Vulns
0
Weekly
0

vite-plugin-proto

npm

Allows you to import proto files as a parsed object directly in your code, uses protobufjs under the hood.

import grpc from '@grpc/grpc-js';
import protoLoader from '@grpc/proto-loader';

import greeterNamespace from './proto/greeter.proto';

const packageDefinition = protoLoader.fromJSON(greeterNamespace);
const packageObject = grpc.loadPackageDefinition(packageDefinition);

Usage

import proto from 'vite-plugin-proto';

export default {
  plugins: [
    proto(),
  ]
}

Options

Option Type Default Description
basePath string ./ The base path that will be used to resolve other .proto files in import statements, useless if you define resolvePath
resolvePath (origin: string, target: string) => string (_, target) => path.resolve(basePath, target) A function that will be used to resolve other .proto files in import statements
parseOptions import('protobufjs').IParseOptions undefined Options that will be passed to protobufjs's load method

Keywords