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: 7 months 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 (8 months ago)
- Default Branch: main
- Last Pushed: 2025-06-28T03:28:20.000Z (7 months ago)
- Last Synced: 2025-06-28T04:26:22.126Z (7 months ago)
- Topics: esbuild, rolldown, rspack, toml, unplugin, vite
- Language: TypeScript
- Homepage:
- Size: 495 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
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 */
}),
],
});
```
Farm
```ts
// farm.config.ts
import { defineConfig } from "@farmfe/core";
import vue from "@vitejs/plugin-vue";
import TOMLPlugin from "unplugin-toml/farm";
export default defineConfig({
vitePlugins: [
vue(),
],
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