{"id":17910900,"url":"https://github.com/sudongyuer/vite-plugin-hot-export","last_synced_at":"2025-03-23T22:33:16.105Z","repository":{"id":44398240,"uuid":"512208214","full_name":"sudongyuer/vite-plugin-hot-export","owner":"sudongyuer","description":"🐝 A vite plugin automatically export files \u0026 HMR support","archived":false,"fork":false,"pushed_at":"2022-09-17T04:45:22.000Z","size":21037,"stargazers_count":55,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T14:38:51.727Z","etag":null,"topics":["auto-export","automatically","hmr","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/sudongyuer.png","metadata":{"files":{"readme":"README-zh.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},"funding":{"github":"sudongyuer"}},"created_at":"2022-07-09T14:36:47.000Z","updated_at":"2025-03-18T03:06:32.000Z","dependencies_parsed_at":"2022-07-14T01:10:40.632Z","dependency_job_id":null,"html_url":"https://github.com/sudongyuer/vite-plugin-hot-export","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudongyuer%2Fvite-plugin-hot-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudongyuer%2Fvite-plugin-hot-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudongyuer%2Fvite-plugin-hot-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudongyuer%2Fvite-plugin-hot-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sudongyuer","download_url":"https://codeload.github.com/sudongyuer/vite-plugin-hot-export/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245179529,"owners_count":20573484,"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":["auto-export","automatically","hmr","vite","vite-plugin"],"created_at":"2024-10-28T19:35:25.987Z","updated_at":"2025-03-23T22:33:15.597Z","avatar_url":"https://github.com/sudongyuer.png","language":"TypeScript","funding_links":["https://github.com/sponsors/sudongyuer"],"categories":[],"sub_categories":[],"readme":"[English](https://github.com/sudongyuer/vite-plugin-hot-export#readme) | 简体中文\n\n# vite-plugin-hot-export\n\n自动导出\n\n[![NPM version](https://badge.fury.io/js/vite-plugin-hot-export.svg)](https://www.npmjs.com/package/vite-plugin-hot-export)\n\n\n\u003cp align='center'\u003e\n\u003cimg src='https://git.poker/sudongyuer/image-bed/blob/master/20220714/vite-plugin-auto-export-logo.1aoaypaggq5c.png?raw=true' width='200'/\u003e\n\u003c/p\u003e\n\n## 为什么 ?\n\n开发时用的image，svg等资源，我们需要手动通过`index.ts`导出, 这款插件就可以解放双手，并且支持`HMR` 🌈\n\n## 🚀 特点\n\n- 👻 支持文件夹批量生成\n- 🍁 自动导出文件\n- 🐥 自定义输出文件\n- 🍄 自定义导入声明\n- ✨ 支持`HMR`\n- 🌈 支持多级目录\n- 🍣 自动添加前缀\n\n\n## 📺 预览\n\n\u003cp align='center'\u003e\n\u003cimg src='https://git.poker/sudongyuer/image-bed/blob/master/20220717/屏幕录制2022-07-17-11.2ia7q69awd00.gif?raw=true' width='100%'/\u003e\n\u003c/p\u003e\n\n\n## 🦄 用法\n\n### 安装\n\n```bash\npnpm add -D vite-plugin-hot-export\n```\n\n### 配置 `export.config.ts`\n\n- `targetDir` (必须) : 目标文件夹\n\n- `outputDir` (可选,默认：目标文件夹) : 通过 `index.ts` 文件导出\n\n- `customImport` (可选) : 通过`index.ts`自定义导入 \n\n- `depth` (可选 , 默认： true) : 递归子目录\n\n- `autoPrefix` (可选 , 默认： false) : 自动给文件加前缀. 注意：如果`customImport`没有配置，则忽略该配置\n\n```js\nimport { defineExportConfig } from 'vite-plugin-hot-export'\nexport default defineExportConfig({\n  configs: [\n    {\n      targetDir: './src/assets/images',\n    },\n    {\n      targetDir: './src/assets/img',\n      depth: true,\n      autoPrefix: true\n    },\n    {\n      targetDir: './src/assets/css',\n      outputDir: './src/assets/css',\n    },\n    {\n      targetDir: './src/assets/svgs',\n      customImport: (fileName, file) =\u003e {\n        return `import { ReactComponent as ${fileName} } from '${file}'`\n      },\n    },\n    {\n      targetDir: './src/assets/gif',\n      customImport: (fileName, file, fileType) =\u003e {\n        return `import ${fileType}${fileName} from '${file}'`\n      },\n      depth: true\n    },\n  ],\n})\n\n```\n\n增加 `vite-plugin-hot-export` 插件到 vite.config.js / vite.config.ts 然后配置它:\n\n```js\n// vite.config.js / vite.config.ts\nimport HotExport from 'vite-plugin-hot-export'\n\nexport default {\n  plugins: [\n    HotExport()\n  ]\n}\n```\n然后起服务\n```bash\npnpm run dev\n```\n## 没有生效?\n\n如果你用的是`webstorm`，请参考:\n\n![image-20220717101450402](https://tva1.sinaimg.cn/large/e6c9d24egy1h49pefcb4jj21580u0wi5.jpg)\n\n\n## 作者\n\nsudongyuer email:976499226@qq.com\n\n## 📄 License\n\n[MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudongyuer%2Fvite-plugin-hot-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsudongyuer%2Fvite-plugin-hot-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudongyuer%2Fvite-plugin-hot-export/lists"}