vite-plugin-proto
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-proto

Weekly Downloads

19

Version

1.0.0

License

GPL-3.0

Unpacked Size

40 kB

Total Files

6

Last publish

Collaborators

  • levyks