vite-plugin-proto
v1.0.0
Published
Plugin to allow importing .proto file as json objects.
Downloads
65
Readme
vite-plugin-proto
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 |