Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sapphi-red/vite-plugin-toml
A plugin for rollup/vite to import a toml file.
https://github.com/sapphi-red/vite-plugin-toml
rollup rollup-plugin vite vite-plugin
Last synced: about 2 months ago
JSON representation
A plugin for rollup/vite to import a toml file.
- Host: GitHub
- URL: https://github.com/sapphi-red/vite-plugin-toml
- Owner: sapphi-red
- License: mit
- Created: 2020-12-17T02:07:37.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-19T10:24:32.000Z (6 months ago)
- Last Synced: 2024-10-01T08:34:24.847Z (about 2 months ago)
- Topics: rollup, rollup-plugin, vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 565 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-toml
[![npm version](https://badge.fury.io/js/vite-plugin-toml.svg)](https://badge.fury.io/js/vite-plugin-toml) ![automatic deploy](https://github.com/sapphi-red/vite-plugin-toml/workflows/automatic%20deploy/badge.svg) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
Toml file plugin for rollup/vite.
> The name starts with `vite-plugin-`, but this is a historical reason.
> This plugin **does** support rollup too.Uses [`toml-eslint-parser` package](https://www.npmjs.com/package/toml-eslint-parser) for parsing.
Supports Toml 1.0.0.## Install
```shell
npm i -D vite-plugin-toml # yarn add -D vite-plugin-toml
```Add plugin in `vite.config.js`.
```js
import { ViteToml } from 'vite-plugin-toml'export default {
plugins: [ViteToml()]
}
```### Options
- `namedExports` (default: `false`)
Enable named exports.
### Typescript
I recommend using [typescript-plugin-toml](https://github.com/sapphi-red/typescript-plugin-toml).
Alternatively, add this global declaration.
```ts
declare module '*.toml' {
const value: unknown
export default value
}
```## Example
`test.toml`
```toml
key = 'value'
````index.ts`
```ts
import test from './test.toml'console.log(test.key) // 'value'
```