{"id":13605277,"url":"https://github.com/kirklin/unplugin-config","last_synced_at":"2025-10-05T23:07:52.870Z","repository":{"id":147209326,"uuid":"618355190","full_name":"kirklin/unplugin-config","owner":"kirklin","description":"🔧 Configuration file generator for web apps, allowing external customization of global variables without repackaging.","archived":false,"fork":false,"pushed_at":"2024-03-20T05:12:11.000Z","size":247,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T20:14:56.638Z","etag":null,"topics":["config","generator","plugin","rollup","unplugin","vite","vite-plugin","webpack"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/unplugin-config","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/kirklin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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},"funding":{"github":"kirklin","patreon":"kirklin","custom":["https://www.buymeacoffee.com/linkirk"]}},"created_at":"2023-03-24T09:40:28.000Z","updated_at":"2025-01-12T08:39:06.000Z","dependencies_parsed_at":"2024-01-07T18:04:45.340Z","dependency_job_id":"f2856af9-393e-4f2d-911e-1bfc8d204097","html_url":"https://github.com/kirklin/unplugin-config","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirklin%2Funplugin-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirklin%2Funplugin-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirklin%2Funplugin-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirklin%2Funplugin-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirklin","download_url":"https://codeload.github.com/kirklin/unplugin-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250506141,"owners_count":21441723,"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":["config","generator","plugin","rollup","unplugin","vite","vite-plugin","webpack"],"created_at":"2024-08-01T19:00:56.921Z","updated_at":"2025-10-05T23:07:47.820Z","avatar_url":"https://github.com/kirklin.png","language":"TypeScript","readme":"# unplugin-config\n\n[![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript_code style][code-style-image]][code-style-url]\n\n[npm-image]: https://img.shields.io/npm/v/unplugin-config.svg\n[npm-url]: https://npmjs.org/package/unplugin-config\n[downloads-image]: https://img.shields.io/npm/dm/unplugin-config.svg\n[downloads-url]: https://npmjs.org/package/unplugin-config\n[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen\n[code-style-url]: https://github.com/kirklin/eslint-config/\n\n\u003cdiv align='center'\u003e\n\u003cb\u003eEnglish\u003c/b\u003e | \u003ca href=\"README.zh-cn.md\"\u003e简体中文\u003c/a\u003e\n\u003cbr\u003e\n\u003c/div\u003e\n\nA tool that generates configuration files for web applications, allowing customization of global variables that can be externally modified without the need for repackaging.\n\n##### Features\n- ✨ Generates configuration files for web applications.\n- 🔨 Allows customization of global variables.\n- 🌈 Built-in support for dotenv, enabling parsing of environment variables starting with a specified prefix.\n- 🚀 Supports packaging with Vite, Webpack, Rollup, and more.\n- 🎉 Tree-shakable, generates only the configuration file required for the application.\n- 🌟 Compatible with TypeScript.\n\n## Install\n\n```bash\nnpm i unplugin-config\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\nimport ConfigPlugin from \"unplugin-config/vite\";\n\nexport default defineConfig({\n  plugins: [\n    ConfigPlugin({ /* options */ }),\n  ],\n});\n```\n\nExample: [`playground/`](./playground/)\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRollup\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// rollup.config.js\nimport ConfigPlugin from \"unplugin-config/rollup\";\n\nexport default {\n  plugins: [\n    ConfigPlugin({ /* options */ }),\n  ],\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// webpack.config.js\nmodule.exports = {\n  /* ... */\n  plugins: [\n    require(\"unplugin-config/webpack\")({ /* options */ })\n  ]\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eNuxt\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// nuxt.config.js\nexport default {\n  buildModules: [\n    [\"unplugin-config/nuxt\", { /* options */ }],\n  ],\n};\n```\n\n\u003e This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vue.config.js\nmodule.exports = {\n  configureWebpack: {\n    plugins: [\n      require(\"unplugin-config/webpack\")({ /* options */ }),\n    ],\n  },\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// esbuild.config.js\nimport { build } from \"esbuild\";\nimport ConfigPlugin from \"unplugin-config/esbuild\";\n\nbuild({\n  plugins: [ConfigPlugin()],\n});\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Configuration\n\nThe `Options` object contains the following properties:\n\n### Application Options (`appName` and `baseDir`)\n\n- `appName` (string, optional): The name of the application.\n- `baseDir` (string, optional): The base directory for the output.\n\n### Configuration File Options (`configFile`)\n\n- `generate` (boolean, optional): Enable or disable generating the configuration file. Default is `true`.\n- `fileName` (string, optional): The name of the global configuration file. Default is `\"config.js\"`.\n- `outputDir` (string, optional): The directory where the configuration file is generated. Default is `\"./dist\"`.\n\n### HTML Injection Options (`htmlInjection`)\n\n- `enable` (boolean, optional): Enable or disable injecting configuration into HTML files. Default is `true`.\n- `templates` (string[], optional): An array of template files to transform.\n- `position` (string, optional): The position where the configuration script is injected into HTML files. Possible values are `\"head\"`, `\"body\"`, `\"head-prepend\"`, or `\"body-prepend\"`. Default is `\"head-prepend\"`.\n- `decodeEntities` (boolean, optional): Whether to decode HTML entities in the injected HTML code. If set to `true`, HTML entities in the injected HTML code will be decoded. Default is `false`.\n\n### Environment Variables Options (`envVariables`)\n\n- `prefix` (string, optional): The prefix for environment variables used in configuration.\n- `files` (string[], optional): An array of configuration files to load environment variables from.\n\n### Example\n\n```javascript\nconst configurationOptions = {\n  appName: \"MyApp\",\n  baseDir: \"/\",\n  configFile: {\n    generate: true,\n    fileName: \"_app.config.js\",\n    outputDir: \"dist\",\n  },\n  htmlInjection: {\n    enable: true,\n    templates: [\"index.html\"],\n    position: \"head-prepend\",\n  },\n  envVariables: {\n    prefix: \"VITE_GLOB_\",\n    files: [\".env.production\", \".env\"],\n  },\n};\n```\n\n## Example\n\n[kirklin/celeris-admin](https://github.com/kirklin/celeris-admin)\n\n## License\n\n[MIT](./LICENSE) License © 2022-PRESENT [Kirk Lin](https://github.com/kirklin)\n","funding_links":["https://github.com/sponsors/kirklin","https://patreon.com/kirklin","https://www.buymeacoffee.com/linkirk"],"categories":["Plugins","webpack"],"sub_categories":["Framework-agnostic Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirklin%2Funplugin-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirklin%2Funplugin-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirklin%2Funplugin-config/lists"}