Skip to content

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

License

Notifications You must be signed in to change notification settings

Levyks/vite-plugin-proto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published