https://github.com/luxass/unplugin-toml
📦 A unplugin that allow import of toml files
https://github.com/luxass/unplugin-toml
esbuild rolldown rspack toml unplugin vite
Last synced: about 20 hours ago
JSON representation
📦 A unplugin that allow import of toml files
- Host: GitHub
- URL: https://github.com/luxass/unplugin-toml
- Owner: luxass
- License: mit
- Created: 2025-05-28T17:40:49.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-04-25T14:50:42.000Z (1 day ago)
- Last Synced: 2026-04-25T16:26:52.942Z (1 day ago)
- Topics: esbuild, rolldown, rspack, toml, unplugin, vite
- Language: TypeScript
- Homepage:
- Size: 1.16 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# unplugin-toml
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
Allow import Toml file for Vite, Webpack, Rollup and esbuild. With TypeScript support. Powered by [unplugin](https://github.com/unjs/unplugin).
## Install
```bash
npm i -D unplugin-toml
```
## Usage
> [!TIP]
> You can view all examples [here](./examples).
Vite
```ts
// vite.config.ts
import TOMLPlugin from "unplugin-toml/vite";
export default defineConfig({
plugins: [
TOMLPlugin({
/* options */
}),
],
});
```
Rollup
```ts
// rollup.config.js
import TOMLPlugin from "unplugin-toml/rollup";
export default {
plugins: [
TOMLPlugin({
/* options */
}),
],
};
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-toml/webpack").default({
/* options */
}),
],
};
```
Nuxt
```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
"unplugin-toml/nuxt",
{
/* options */
},
],
],
});
```
Astro
```ts
// astro.config.mjs
import { defineConfig } from "astro/config";
import TOMLPlugin from "unplugin-toml/astro";
// https://astro.build/config
export default defineConfig({
integrations: [
TOMLPlugin({
/* options */
}),
],
});
```
esbuild
```ts
// esbuild.config.js
import { build } from "esbuild";
import TOMLPlugin from "unplugin-toml/esbuild";
build({
/* ... */
plugins: [
TOMLPlugin({
/* options */
}),
],
});
```
Rspack
```ts
// rspack.config.mjs
import rspack from "@rspack/core";
import TOMLPlugin from "unplugin-toml/rspack";
/** @type {import('@rspack/core').Configuration} */
export default {
plugins: [
new rspack.HtmlRspackPlugin({
template: "./index.html",
}),
TOMLPlugin(),
],
};
```
Rolldown (Experimental)
```ts
// rolldown.config.js
import { defineConfig } from "rolldown";
import TOMLPlugin from "unplugin-toml/rolldown";
export default defineConfig({
input: "./index.js",
plugins: [
TOMLPlugin({
/* options */
}),
],
});
```
## Configuration
```ts
TOMLPlugin({
include: [
/\.tomlcustom$/, // .tomlcustom
],
parserOptions: {
// see toml load options
},
});
```
### TypeScript
If you are using TypeScript, you need to add the following to your `tsconfig.json` file:
```json
{
"compilerOptions": {
"types": ["unplugin-toml/types"]
}
}
```
## 📄 License
Published under [MIT License](./LICENSE).
[npm-version-src]: https://img.shields.io/npm/v/unplugin-toml?style=flat&colorA=18181B&colorB=4169E1
[npm-version-href]: https://npmjs.com/package/unplugin-toml
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-toml?style=flat&colorA=18181B&colorB=4169E1
[npm-downloads-href]: https://npmjs.com/package/unplugin-toml