{"id":22531952,"url":"https://github.com/yue1123/vite-plugin-env-parse","last_synced_at":"2025-04-05T04:11:09.676Z","repository":{"id":159891651,"uuid":"634582781","full_name":"yue1123/vite-plugin-env-parse","owner":"yue1123","description":"Parse env string values to correct values, not all values are strings. And automatically generate ImportMetaEnv","archived":false,"fork":false,"pushed_at":"2025-01-09T19:47:25.000Z","size":1843,"stargazers_count":76,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T03:11:16.863Z","etag":null,"topics":["env","env-parse","environment-variables","environments","import-meta-env","vite","vite-plugin"],"latest_commit_sha":null,"homepage":"","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/yue1123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":"https://yue1123.github.io/vue3-baidu-map-gl/sponsor"}},"created_at":"2023-04-30T15:49:46.000Z","updated_at":"2025-02-17T03:27:28.000Z","dependencies_parsed_at":"2023-12-19T08:07:46.799Z","dependency_job_id":"0c4111a4-a0c8-4ed8-a9e2-9dec46ebe2d5","html_url":"https://github.com/yue1123/vite-plugin-env-parse","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"d2afd7d84da79956fe0b4c7a38c13f89d4f2a9e1"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue1123%2Fvite-plugin-env-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue1123%2Fvite-plugin-env-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue1123%2Fvite-plugin-env-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue1123%2Fvite-plugin-env-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yue1123","download_url":"https://codeload.github.com/yue1123/vite-plugin-env-parse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284949,"owners_count":20913704,"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":["env","env-parse","environment-variables","environments","import-meta-env","vite","vite-plugin"],"created_at":"2024-12-07T08:09:17.756Z","updated_at":"2025-04-05T04:11:09.654Z","avatar_url":"https://github.com/yue1123.png","language":"TypeScript","funding_links":["https://yue1123.github.io/vue3-baidu-map-gl/sponsor"],"categories":[],"sub_categories":[],"readme":"# vite-plugin-env-parse\n\n![npm](https://img.shields.io/npm/v/vite-plugin-env-parse?style=flat-square)\n![npm](https://img.shields.io/npm/dm/vite-plugin-env-parse?style=flat-square)\n![GitHub](https://img.shields.io/github/license/yue1123/vite-plugin-env-parse?style=flat-square)\n\n[简体中文](./README.zh.md)\n\nParse env string values to correct values, not all values are strings. And automatically generate ImportMetaEnv\n\n![showcase](./screenshots/showcase.png)\n\n## 📦 Install\n\n```shell\nnpm i vite-plugin-env-parse -D\n\n# yarn\nyarn add vite-plugin-env-parse -D\n\n# pnpm\npnpm add vite-plugin-env-parse -D\n```\n\n## 🦄 Usage\n\nAdd envParse plugin to vite.config.js / vite.config.ts and configure it:\n\n```ts\n// vite.config.js / vite.config.ts\nimport { envParse } from 'vite-plugin-env-parse'\n\nexport default {\n  plugins: [envParse()]\n}\n```\n\nAdd include configuration to the `tsconfig.json` file.\n\n\u003e Ignore this step if the project `tsconfig.json` `include` configuration already contains `*.d.ts`\n\u003e \n```json\n{\n  \"include\": [\"env.d.ts\"]\n}\n```\n\n[Example](./example)\n\n## API\n\n### Method\n\nThe `parseLoadedEnv` utility function can be used in the `vite config` file to parse the env environment variable values.\n\n```ts\n// vite.config.ts\nimport { parseLoadedEnv } from 'vite-plugin-env-parse'\nimport { defineConfig, loadEnv } from 'vite'\n\nexport default defineConfig(({ mode }) =\u003e {\n  console.log('vite.config.ts', parseLoadedEnv(loadEnv(mode, './')))\n\n  return {\n    plugins: [envParse({})]\n  }\n})\n```\n\n### EnvParseOptions\n\n| Property       | Type                | Description                                                                        |\n| -------------- | ------------------- | ---------------------------------------------------------------------------------- |\n| `exclude`      | `string[]`          | A list of environment variable keys to exclude from parsing. Optional.             |\n| `parseJson`    | `boolean`           | Whether to parse JSON strings into JSON objects. Defaults to `true`. Optional.     |\n| `customParser` | `CustomTransformer` | A custom transformer function for parsing environment variables. Optional.         |\n| `dtsPath`      | `string`            | The file path for generating the `.d.ts` file. Defaults to `'env.d.ts'`. Optional. |\n\n## License\n\n[MIT licenses](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyue1123%2Fvite-plugin-env-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyue1123%2Fvite-plugin-env-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyue1123%2Fvite-plugin-env-parse/lists"}