{"id":16742053,"url":"https://github.com/zheeeng/vite-plugin-plain-text","last_synced_at":"2026-03-14T13:09:39.691Z","repository":{"id":57393169,"uuid":"372546140","full_name":"zheeeng/vite-plugin-plain-text","owner":"zheeeng","description":"A Vite plugin transforms the rule-matched file as plain text.","archived":false,"fork":false,"pushed_at":"2023-02-02T03:26:44.000Z","size":54,"stargazers_count":24,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T13:41:28.763Z","etag":null,"topics":["plaintext","plugin","vite","vite-plugin","vite-plugin-plain-text","vitejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vite-plugin-plain-text","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zheeeng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-31T15:07:17.000Z","updated_at":"2024-10-14T07:58:07.000Z","dependencies_parsed_at":"2023-02-17T13:46:06.498Z","dependency_job_id":null,"html_url":"https://github.com/zheeeng/vite-plugin-plain-text","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.03703703703703709,"last_synced_commit":"f699878b96b91cf813f6ad1895554408374ffb46"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-plain-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-plain-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-plain-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-plain-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zheeeng","download_url":"https://codeload.github.com/zheeeng/vite-plugin-plain-text/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880235,"owners_count":20525505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plaintext","plugin","vite","vite-plugin","vite-plugin-plain-text","vitejs"],"created_at":"2024-10-13T01:08:29.611Z","updated_at":"2026-03-14T13:09:39.664Z","avatar_url":"https://github.com/zheeeng.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-plain-text\n\n[![NPM](https://nodei.co/npm/vite-plugin-plain-text.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/vite-plugin-plain-text/)\n\n![publish workflow](https://github.com/zheeeng/vite-plugin-plain-text/actions/workflows/publish.yml/badge.svg)\n[![npm version](https://img.shields.io/npm/v/vite-plugin-plain-text.svg)](https://www.npmjs.com/package/vite-plugin-plain-text)\n\nA Vite plugin that transforms matched files into plain text.\n\n## Installation\n\n```bash\npnpm i -D vite-plugin-plain-text (or npm/yarn)\n```\n\n## Usage Example\n\nAssume we are going to transform these files:\n\n1. The project's `LICENSE` file\n2. Textbox\n3. `.glsl` file\n\ninto plain text.\n\n```ts\n// vite.config.(t|j)s\n\nimport { defineConfig } from 'vite';\n\nimport plainText from 'vite-plugin-plain-text';\n\nexport default defineConfig({\n  plugins: [\n    // passing regular expression or glob matcher\n    plainText([/\\/LICENSE$/, '**/*.text', /\\.glsl$/]),\n  ],\n});\n```\n\n```js component.js\n// component.js\n\nimport { plainText as LICENSE } from '../LICENSE'\nimport { plainText as Lorem } from '../lorem-ipsum.text'\nimport { plainText as Siren } from '../siren.glsl'\n\nconsole.log(LICENSE)\nconsole.log(Lorem)\nconsole.log(Siren)\n```\n\n## Advanced Usage\n\n### Options Reference\n\n```ts\ntype PlainTextOptions = {\n  namedExport?: string | false,\n  dtsAutoGen?: boolean,\n  distAutoClean?: boolean,\n}\n```\n\n### Enable Default Export\n\nUse the `plainTextOptions.namedExport` option to configure the named exported variable. To enable the default export, pass `false`, `''`, or `undefined`.\n\n```ts\n// vite.config.(t|j)s\n\nimport { defineConfig } from 'vite';\nimport plainText from 'vite-plugin-plain-text';\n\nexport default defineConfig({\n  plugins: [\n    plainText(\n      [/\\/LICENSE$/, '**/*.text', /\\.glsl$/],\n      { namedExport: false },\n    ),\n  ],\n});\n```\n\n```js component.js\n// component.js\n\nimport LICENSE from '../LICENSE'\nimport Lorem from '../lorem-ipsum.text'\nimport Siren from '../siren.glsl'\n\nconsole.log(LICENSE)\nconsole.log(Lorem)\nconsole.log(Siren)\n```\n\n### Type Safety\n\n#### Adding Module Declarations Manually\n\n```ts\n// vite-env.d.ts\ndeclare module '*/LICENSE' {\n    export const plainText: string\n}\ndeclare module '*.text' {\n    export const plainText: string\n}\ndeclare module '*.glsl' {\n    export const plainText: string\n}\n```\n\n#### Generate the declaration automatically\n\n1. `plainTextOptions.dtsAutoGen` generates `.dts` files for matched files.\n2. `plainTextOptions.dtsAutoClean` cleans up these `.dts` files after the vite plugin starts up each time.\n\n```ts\nimport { defineConfig } from 'vite';\nimport plainText from 'vite-plugin-plain-text';\n\nexport default defineConfig({\n  plugins: [\n    plainText(\n      [/\\/LICENSE$/, '**/*.text', /\\.glsl$/],\n      { namedExport: false, dtsAutoGen: true, distAutoClean: true },\n    ),\n  ],\n});\n```\n\n## License\n\nMIT\n\n## Alternative\n\nVirtual asset Loader: [vite-plugin-virtual-plain-text](https://www.npmjs.com/package/vite-plugin-virtual-plain-text)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzheeeng%2Fvite-plugin-plain-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzheeeng%2Fvite-plugin-plain-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzheeeng%2Fvite-plugin-plain-text/lists"}