{"id":18930819,"url":"https://github.com/onlymisaky/vite-plugin-define-env","last_synced_at":"2025-10-13T22:42:58.243Z","repository":{"id":57393082,"uuid":"465581630","full_name":"onlymisaky/vite-plugin-define-env","owner":"onlymisaky","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-03T09:56:00.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T22:47:16.710Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onlymisaky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-03T05:32:20.000Z","updated_at":"2022-05-30T04:34:40.000Z","dependencies_parsed_at":"2022-09-15T02:21:57.343Z","dependency_job_id":null,"html_url":"https://github.com/onlymisaky/vite-plugin-define-env","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlymisaky%2Fvite-plugin-define-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlymisaky%2Fvite-plugin-define-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlymisaky%2Fvite-plugin-define-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlymisaky%2Fvite-plugin-define-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onlymisaky","download_url":"https://codeload.github.com/onlymisaky/vite-plugin-define-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927816,"owners_count":19719835,"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":[],"created_at":"2024-11-08T11:39:03.650Z","updated_at":"2025-10-13T22:42:53.200Z","avatar_url":"https://github.com/onlymisaky.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-define-env\n\n## 介绍\n\nVue-cli 项目迁移到 vite 时，需要将原有的环境变量前缀从 `VUE_APP_` 修改为 `VITE_` ，同时将业务代码中的 `process.env.VUE_APP_XXX` 修改为 `import.meta.env.VITE_XXX` 。如果你不想手动完成这一工作，可以尝试使用本插件，不需要修改任何业务代码即可轻松完成环境变量的迁移和使用。\n\n同时，如果你不喜欢 `vite` 将环境变量定义到 `import.meta.env` 这一方式，你也可以使用本插件来代替 `define` 这一配置项。\n\n## 安装\n\n```bash\nnpm i vite-plugin-define-env -D\n\nyarn add vite-plugin-define-env -D\n```\n\n## 使用\n```ts\n// vite.config.ts\nimport { defineConfig } from \"vite\";\nimport defineEnv from \"vite-plugin-define-env\";\n\nexport default defineConfig({\n  ...\n  plugins: [defineEnv()]\n});\n```\n\n## 配置项\n\n```ts\ninterface Options {\n  path: string; // .env 文件所在的目录，默认为跟目录\n  key: string; // 要定义的环境变量名称，默认为 process.env\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonlymisaky%2Fvite-plugin-define-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonlymisaky%2Fvite-plugin-define-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonlymisaky%2Fvite-plugin-define-env/lists"}