# vite-plugin-proto

> Plugin to allow importing .proto file as json objects.

Latest version **1.0.0** (published 2023-04-22) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-proto
pnpm add vite-plugin-proto
yarn add vite-plugin-proto
bun add vite-plugin-proto
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-04-22 |
| First published | 2023-04-22 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 39.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Levy Barbosa |
| Maintainers | levyks |
| Keywords | vite, vite-plugin |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-proto
- Repository: https://github.com/Levyks/vite-plugin-proto
- Homepage: https://github.com/Levyks/vite-plugin-proto#readme
- Issues: https://github.com/Levyks/vite-plugin-proto/issues
- npm.io page: https://npm.io/package/vite-plugin-proto

## Dependencies (1)

- [protobufjs](https://npm.io/package/protobufjs.md) ^7.2.3

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-04-22
- 0.0.3 — 2023-04-22
- 0.0.2 — 2023-04-22
- 0.0.1 — 2023-04-22

## README

# vite-plugin-proto

[![npm](https://img.shields.io/npm/v/vite-plugin-proto.svg)](https://www.npmjs.com/package/vite-plugin-proto)

> Allows you to import proto files as a parsed object directly in your code, uses protobufjs under the hood.

```ts
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

```ts
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 |

---
_Source: https://npm.io/package/vite-plugin-proto · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
