├── .github ├── FUNDING.yml └── workflows │ └── changeset-version.yml ├── .npmrc ├── packages ├── vite-plugin-hot-export │ ├── test │ │ ├── a.ts │ │ ├── b.ts │ │ ├── hello │ │ │ └── d.ts │ │ └── index.test.ts │ ├── .eslintrc │ ├── build.config.ts │ ├── tsconfig.json │ ├── CHANGELOG.md │ ├── package.json │ ├── README.md │ └── src │ │ └── index.ts └── client │ ├── src │ ├── vite-env.d.ts │ ├── images │ │ ├── icon.png │ │ ├── react.png │ │ ├── spotify.png │ │ └── index.ts │ ├── main.tsx │ ├── index.css │ ├── custom.d.ts │ ├── App.css │ ├── svgs │ │ ├── index.ts │ │ ├── android.svg │ │ ├── hipster-ipod-music.svg │ │ ├── camera-hipster-on-trend.svg │ │ ├── hipster-on-trend-pipe.svg │ │ ├── book-hipster-on-trend.svg │ │ ├── cassette-hipster-music.svg │ │ ├── bow-fashion-hipster.svg │ │ ├── hipster-music-on-trend.svg │ │ └── headphones-hipster-music.svg │ ├── App.tsx │ ├── favicon.svg │ └── logo.svg │ ├── tsconfig.node.json │ ├── CHANGELOG.md │ ├── .gitignore │ ├── index.html │ ├── export.config.ts │ ├── vite.config.ts │ ├── tsconfig.json │ └── package.json ├── pnpm-workspace.yaml ├── logo.png ├── priview.gif ├── .gitignore ├── .vscode └── settings.json ├── .changeset ├── config.json └── README.md ├── turbo.json ├── LICENSE ├── package.json ├── README-zh.md ├── README_zh-cn.md └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: sudongyuer 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | ignore-workspace-root-check=true 2 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/test/a.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/test/b.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/test/hello/d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/*' 3 | -------------------------------------------------------------------------------- /packages/client/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudongyuer/vite-plugin-hot-export/HEAD/logo.png -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@sudongyuer" 3 | } 4 | -------------------------------------------------------------------------------- /priview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudongyuer/vite-plugin-hot-export/HEAD/priview.gif -------------------------------------------------------------------------------- /packages/client/src/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudongyuer/vite-plugin-hot-export/HEAD/packages/client/src/images/icon.png -------------------------------------------------------------------------------- /packages/client/src/images/react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudongyuer/vite-plugin-hot-export/HEAD/packages/client/src/images/react.png -------------------------------------------------------------------------------- /packages/client/src/images/spotify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudongyuer/vite-plugin-hot-export/HEAD/packages/client/src/images/spotify.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .DS_Store 3 | .eslintcache 4 | *.log 5 | *.tgz 6 | dist 7 | node_modules 8 | .turbo 9 | build/** 10 | dist/** 11 | .next/** 12 | -------------------------------------------------------------------------------- /packages/client/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "esnext", 5 | "moduleResolution": "node" 6 | }, 7 | "include": ["vite.config.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "prettier.enable": false, 3 | "editor.codeActionsOnSave": { 4 | "source.fixAll.eslint": true 5 | }, 6 | "cSpell.words": [ 7 | "sudongyuer" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /packages/client/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # client 2 | 3 | ## 0.0.2 4 | 5 | ### Patch Changes 6 | 7 | - c403f16: update preivew gif 8 | 9 | ## 0.0.1 10 | 11 | ### Patch Changes 12 | 13 | - 8dfc5a8: release v0.1.0 14 | -------------------------------------------------------------------------------- /packages/client/src/images/index.ts: -------------------------------------------------------------------------------- 1 | import PngIcon from './icon.png' 2 | import PngReact from './react.png' 3 | import PngSpotify from './spotify.png' 4 | 5 | export { 6 | PngIcon, 7 | PngReact, 8 | PngSpotify, 9 | } 10 | -------------------------------------------------------------------------------- /packages/client/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/build.config.ts: -------------------------------------------------------------------------------- 1 | import { defineBuildConfig } from 'unbuild' 2 | 3 | export default defineBuildConfig({ 4 | entries: [ 5 | 'src/index', 6 | ], 7 | declaration: true, 8 | clean: true, 9 | rollup: { 10 | emitCJS: true, 11 | }, 12 | externals: ['vite'], 13 | }) 14 | -------------------------------------------------------------------------------- /packages/client/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2019", 4 | "module": "esnext", 5 | "lib": ["esnext"], 6 | "moduleResolution": "node", 7 | "esModuleInterop": true, 8 | "strict": true, 9 | "strictNullChecks": true, 10 | "resolveJsonModule": true, 11 | "skipLibCheck": true, 12 | "skipDefaultLibCheck": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite App 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/client/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.0.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "master", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [], 11 | "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { 12 | "updateInternalDependents": "always" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/client/export.config.ts: -------------------------------------------------------------------------------- 1 | import { defineExportConfig } from 'vite-plugin-hot-export' 2 | 3 | export default defineExportConfig({ 4 | configs: [ 5 | { 6 | targetDir: './src/svgs/', 7 | customImport: (fileName, file) => { 8 | return `import { ReactComponent as Svg${fileName} } from './${file}'` 9 | }, 10 | }, 11 | { 12 | targetDir: './src/images/', 13 | autoPrefix: true, 14 | }, 15 | ], 16 | }) 17 | -------------------------------------------------------------------------------- /packages/client/src/custom.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.svg' { 2 | import * as React from 'react' 3 | export const ReactComponent: React.FC> 4 | const src: string 5 | export default src 6 | } 7 | 8 | declare module '*.jpg' { 9 | const content: string 10 | export default content 11 | } 12 | 13 | declare module '*.png' { 14 | const content: string 15 | export default content 16 | } 17 | 18 | declare module '*.json' { 19 | const content: string 20 | export default content 21 | } 22 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /packages/client/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | import Inspect from 'vite-plugin-inspect' 4 | import HotExport from 'vite-plugin-hot-export' 5 | import svgr from 'vite-plugin-svgr' 6 | import ReactInspector from 'vite-plugin-react-inspector' 7 | // https://vitejs.dev/config/ 8 | export default defineConfig({ 9 | plugins: [ReactInspector(), HotExport(), Inspect(), react(), svgr({ 10 | svgrOptions: { 11 | icon: true, 12 | // ...svgr options (https://react-svgr.com/docs/options/) 13 | }, 14 | })], 15 | }, 16 | ) 17 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turborepo.org/schema.json", 3 | "baseBranch": "origin/master", 4 | "pipeline": { 5 | "build": { 6 | "dependsOn": [ 7 | "^build" 8 | ], 9 | "outputs": [ 10 | ".next/**", 11 | "dist/**", 12 | "build/**" 13 | ] 14 | }, 15 | "test": { 16 | "dependsOn": ["build"], 17 | "outputs": [], 18 | "inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts", "test/**/*.tsx"] 19 | }, 20 | "deploy": { 21 | "dependsOn": ["build", "test"], 22 | "outputs": [] 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": true, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": false, 11 | "forceConsistentCasingInFileNames": false, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx" 18 | }, 19 | "include": ["src"], 20 | "references": [{ "path": "./tsconfig.node.json" }] 21 | } 22 | -------------------------------------------------------------------------------- /packages/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "client", 3 | "type": "module", 4 | "version": "0.0.2", 5 | "private": true, 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "react": "^18.0.0", 13 | "react-dom": "^18.0.0" 14 | }, 15 | "devDependencies": { 16 | "@types/react": "^18.0.0", 17 | "@types/react-dom": "^18.0.0", 18 | "@vitejs/plugin-react": "^1.3.0", 19 | "typescript": "^4.6.3", 20 | "vite": "^2.9.9", 21 | "vite-plugin-hot-export": "workspace:*", 22 | "vite-plugin-inspect": "^0.5.1", 23 | "vite-plugin-react-inspector": "^0.0.5", 24 | "vite-plugin-svgr": "^2.2.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/client/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | 40 | button { 41 | font-size: calc(10px + 2vmin); 42 | } 43 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import { cwd } from 'node:process' 3 | import fs from 'fs' 4 | import { describe, expect, it } from 'vitest' 5 | describe('should', () => { 6 | it('exported', () => { 7 | expect(1).toEqual(1) 8 | }) 9 | }) 10 | 11 | it('getCurrentDirFilesCount', () => { 12 | function getCurrentDirFilesCount(targetDir: string) { 13 | let filesLength = 0 14 | const DirAndFiles = fs.readdirSync(path.resolve(cwd(), targetDir)) 15 | for (let i = 0; i < DirAndFiles.length; i++) { 16 | const file = DirAndFiles[i] 17 | const filePath = path.resolve(cwd(), targetDir, file) 18 | const stats = fs.statSync(filePath) 19 | if (stats.isFile()) 20 | filesLength++ 21 | else 22 | filesLength += getCurrentDirFilesCount(filePath) 23 | } 24 | return filesLength 25 | } 26 | 27 | const length = getCurrentDirFilesCount(path.resolve(cwd(), './')) 28 | expect(length).toBe(4) 29 | }) 30 | -------------------------------------------------------------------------------- /packages/client/src/svgs/index.ts: -------------------------------------------------------------------------------- 1 | import { ReactComponent as SvgAndroid } from './android.svg' 2 | import { ReactComponent as SvgBookHipsterOnTrend } from './book-hipster-on-trend.svg' 3 | import { ReactComponent as SvgBowFashionHipster } from './bow-fashion-hipster.svg' 4 | import { ReactComponent as SvgCameraHipsterOnTrend } from './camera-hipster-on-trend.svg' 5 | import { ReactComponent as SvgCassetteHipsterMusic } from './cassette-hipster-music.svg' 6 | import { ReactComponent as SvgHeadphonesHipsterMusic } from './headphones-hipster-music.svg' 7 | import { ReactComponent as SvgHipsterIpodMusic } from './hipster-ipod-music.svg' 8 | import { ReactComponent as SvgHipsterMusicOnTrend } from './hipster-music-on-trend.svg' 9 | import { ReactComponent as SvgHipsterOnTrendPipe } from './hipster-on-trend-pipe.svg' 10 | 11 | export { 12 | SvgAndroid, 13 | SvgBookHipsterOnTrend, 14 | SvgBowFashionHipster, 15 | SvgCameraHipsterOnTrend, 16 | SvgCassetteHipsterMusic, 17 | SvgHeadphonesHipsterMusic, 18 | SvgHipsterIpodMusic, 19 | SvgHipsterMusicOnTrend, 20 | SvgHipsterOnTrendPipe 21 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 SuDongYu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/client/src/App.tsx: -------------------------------------------------------------------------------- 1 | import './App.css' 2 | import { PngSpotify } from './images' 3 | import logo from './logo.svg' 4 | import { SvgAndroid, SvgBookHipsterOnTrend, SvgCameraHipsterOnTrend, SvgHipsterOnTrendPipe } from './svgs' 5 | 6 | function App() { 7 | return ( 8 |
9 |
10 | logo 11 | logo 12 | 16 |

21 | 22 | 23 | 24 | 25 |

26 |

vite-plugin-hot-export

27 |

28 | GitHub 👉 sudongyuer 🐟 29 |

30 | {/* */} 31 |
32 |
33 | ) 34 | } 35 | 36 | export default App 37 | -------------------------------------------------------------------------------- /.github/workflows/changeset-version.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | env: 8 | CI: true 9 | PNPM_CACHE_FOLDER: .pnpm-store 10 | 11 | jobs: 12 | release: 13 | name: Release 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: checkout code repository 17 | uses: actions/checkout@v2 18 | with: 19 | fetch-depth: 0 20 | 21 | - name: setup node.js 22 | uses: actions/setup-node@v2 23 | with: 24 | node-version: 14 25 | 26 | - name: Setup pnpm 27 | uses: pnpm/action-setup@v2.2.2 28 | with: 29 | version: 6 30 | 31 | - name: install dependencies 32 | run: pnpm install 33 | 34 | - name: Create Release Pull Request or Publish to npm 35 | # https://github.com/changesets/action 36 | uses: changesets/action@v1 37 | with: 38 | # this expects you to have a script called release which does a build for your packages and calls changeset publish 39 | publish: pnpm run release 40 | version: pnpm run version 41 | commit: 'chore: update versions' 42 | title: 'chore: update versions' 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.THE_GITHUB_TOKEN }} 45 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 46 | -------------------------------------------------------------------------------- /packages/client/src/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/client/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/client/src/svgs/android.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # vite-plugin-hot-export 2 | 3 | ## 0.5.9 4 | 5 | ### Patch Changes 6 | 7 | - 086c25a: 🦥 fix change fileName 8 | 9 | ## 0.5.8 10 | 11 | ### Patch Changes 12 | 13 | - e1341f5: release: v0.5.8 14 | 15 | ## 0.5.7 16 | 17 | ### Patch Changes 18 | 19 | - dca4c60: release v0.5.6 20 | 21 | ## 0.5.6 22 | 23 | ### Patch Changes 24 | 25 | - 5858ba5: fix: window path compatibility 26 | 27 | ## 0.5.5 28 | 29 | ### Patch Changes 30 | 31 | - e5314c6: update auto-export v0.3.3 32 | 33 | ## 0.5.4 34 | 35 | ### Patch Changes 36 | 37 | - 7b3efec: update package bin 38 | 39 | ## 0.5.3 40 | 41 | ### Patch Changes 42 | 43 | - e0d11f2: update dep 44 | 45 | ## 0.5.2 46 | 47 | ### Patch Changes 48 | 49 | - 87d8a42: update readme explain new config 50 | 51 | ## 0.5.1 52 | 53 | ### Patch Changes 54 | 55 | - 9e06716: update readme.md 56 | 57 | ## 0.5.0 58 | 59 | ### Minor Changes 60 | 61 | - fc151a7: - Nested directory generate support 🌈 62 | - Auto Prefix support 🍣 63 | - Optimize generate ✨ 64 | 65 | ### Patch Changes 66 | 67 | - d5feccf: update README.md 68 | 69 | ## 0.4.3 70 | 71 | ### Patch Changes 72 | 73 | - 8fc6bde: update 74 | 75 | ## 0.4.2 76 | 77 | ### Patch Changes 78 | 79 | - 41b62ce: update README.md 80 | 81 | ## 0.4.1 82 | 83 | ### Patch Changes 84 | 85 | - cde5d47: update README.md 86 | 87 | ## 0.4.0 88 | 89 | ### Minor Changes 90 | 91 | - 57cc873: fix: vite build process not exit 92 | 93 | ## 0.3.0 94 | 95 | ### Minor Changes 96 | 97 | - 4241ddc: release v0.2.0 98 | 99 | ## 0.2.0 100 | 101 | ### Minor Changes 102 | 103 | - c403f16: update preivew gif 104 | 105 | ## 0.1.0 106 | 107 | ### Minor Changes 108 | 109 | - 8dfc5a8: release v0.1.0 110 | 111 | ## 0.0.1 112 | 113 | ### Patch Changes 114 | 115 | - 63f12a7: release v0.1.0 116 | -------------------------------------------------------------------------------- /packages/client/src/svgs/hipster-ipod-music.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-plugin-hot-export-monorepo", 3 | "version": "0.5.0", 4 | "packageManager": "pnpm@7.1.5", 5 | "description": "", 6 | "author": "sudongyuer", 7 | "license": "MIT", 8 | "funding": "https://github.com/sponsors/sudongyuer", 9 | "homepage": "https://github.com/sudongyuer/vite-plugin-hot-export#readme", 10 | "repository": "https://github.com/sudongyuer/vite-plugin-hot-export", 11 | "bugs": "https://github.com/sudongyuer/vite-plugin-hot-export/issues", 12 | "keywords": [], 13 | "exports": { 14 | ".": { 15 | "types": "./dist/index.d.ts", 16 | "require": "./dist/index.cjs", 17 | "import": "./dist/index.mjs" 18 | } 19 | }, 20 | "main": "./dist/index.mjs", 21 | "module": "./dist/index.mjs", 22 | "types": "./dist/index.d.ts", 23 | "typesVersions": { 24 | "*": { 25 | "*": [ 26 | "./dist/*", 27 | "./dist/index.d.ts" 28 | ] 29 | } 30 | }, 31 | "files": [ 32 | "dist" 33 | ], 34 | "scripts": { 35 | "dev": "unbuild --stub", 36 | "build": "unbuild", 37 | "test": "vitest", 38 | "changeset": "changeset add", 39 | "typecheck": "tsc --noEmit", 40 | "lint": "eslint . --cache", 41 | "lint-fix": "eslint . --fix", 42 | "try": "tsx src/index.ts", 43 | "auto-export": "pnpm export", 44 | "build:all": "pnpm turbo run build", 45 | "version": "changeset version", 46 | "release": "pnpm build:all && pnpm release:only", 47 | "release:only": "changeset publish", 48 | "remove:node_modules": "pnpx rimraf ./**/node_modules" 49 | }, 50 | "devDependencies": { 51 | "@changesets/cli": "^2.23.1", 52 | "@sudongyuer/eslint-config": "^0.1.3", 53 | "@types/node": "^18.0.0", 54 | "eslint": "^8.18.0", 55 | "pnpm": "^6.3.0", 56 | "tsx": "^3.6.0", 57 | "turbo": "^1.2.16", 58 | "typescript": "^4.7.4", 59 | "unbuild": "^0.7.4", 60 | "vite": "^2.9.12", 61 | "vitest": "^0.15.2" 62 | }, 63 | "eslintConfig": { 64 | "extends": [ 65 | "@sudongyuer" 66 | ] 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /packages/client/src/svgs/camera-hipster-on-trend.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-plugin-hot-export", 3 | "type": "module", 4 | "version": "0.5.9", 5 | "packageManager": "pnpm@7.1.5", 6 | "description": "", 7 | "author": "sudongyuer", 8 | "license": "MIT", 9 | "funding": "https://github.com/sponsors/sudongyuer", 10 | "homepage": "https://github.com/sudongyuer/vite-plugin-hot-export#readme", 11 | "repository": "https://github.com/sudongyuer/vite-plugin-hot-export", 12 | "bugs": "https://github.com/sudongyuer/vite-plugin-hot-export/issues", 13 | "keywords": [ 14 | "vite", 15 | "vite-plugin", 16 | "vite-plugin-hot-export" 17 | ], 18 | "exports": { 19 | ".": { 20 | "types": "./dist/index.d.ts", 21 | "require": "./dist/index.cjs", 22 | "import": "./dist/index.mjs" 23 | } 24 | }, 25 | "main": "./dist/index.mjs", 26 | "module": "./dist/index.mjs", 27 | "types": "./dist/index.d.ts", 28 | "typesVersions": { 29 | "*": { 30 | "*": [ 31 | "./dist/*", 32 | "./dist/index.d.ts" 33 | ] 34 | } 35 | }, 36 | "files": [ 37 | "dist" 38 | ], 39 | "scripts": { 40 | "dev": "unbuild --stub --declaration", 41 | "build": "unbuild", 42 | "test": "vitest", 43 | "version": "changeset version", 44 | "changeset": "changeset add", 45 | "release": "pnpm run build && pnpm run release:only", 46 | "release:only": "changeset publish", 47 | "typecheck": "tsc --noEmit", 48 | "lint": "eslint . --cache", 49 | "lint-fix": "eslint . --fix", 50 | "try": "tsx src/index.ts" 51 | }, 52 | "dependencies": { 53 | "auto-export": "^0.3.7", 54 | "chokidar": "^3.5.3", 55 | "unconfig": "^0.3.5" 56 | }, 57 | "devDependencies": { 58 | "@sudongyuer/eslint-config": "^0.1.3", 59 | "@types/node": "^18.0.0", 60 | "eslint": "^8.18.0", 61 | "pnpm": "^7.3.0", 62 | "tsx": "^3.6.0", 63 | "typescript": "^4.7.4", 64 | "unbuild": "^0.7.4", 65 | "vite": "^2.9.12", 66 | "vitest": "^0.15.2" 67 | }, 68 | "eslintConfig": { 69 | "extends": [ 70 | "@sudongyuer" 71 | ] 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /packages/client/src/svgs/hipster-on-trend-pipe.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/client/src/svgs/book-hipster-on-trend.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/README.md: -------------------------------------------------------------------------------- 1 | # vite-plugin-hot-export 2 | 3 | 4 | 5 | Automatically export files with HMR 6 | 7 | [![NPM version](https://img.shields.io/github/package-json/v/sudongyuer/vite-plugin-hot-export)](https://www.npmjs.com/package/vite-plugin-hot-export) 8 | 9 | 10 |

11 | 12 |

13 | 14 | ## Why ? 15 | 16 | When developing, we often need to download some `images` or `svg` from the internet, and when we need to use them, we need export them in `index.ts` file `manually`, this plugin can handle this for you `automatically`.And support HMR 🌈 17 | 18 | ## 🚀 Features 19 | 20 | - Multiple directory generate support 21 | - Auto export files 22 | - custom outputDir 23 | - 🍄 Support custom import statement 24 | - ✨ HMR support 25 | 26 | ## 📺 Preview 27 | 28 |

29 | 30 |

31 | 32 | 33 | ## 🦄 Usage 34 | 35 | ### Install 36 | 37 | ```bash 38 | pnpm add -D vite-plugin-hot-export 39 | ``` 40 | 41 | ### Config `export.config.ts` 42 | 43 | - targetDir (require) : the directory to export files 44 | 45 | - outputDir (optional): the directory to generate the `index.ts` file to export files 46 | 47 | - customImport (optional): custom the import statement to use in the `index.ts` file 48 | 49 | ```js 50 | import { defineExportConfig } from 'vite-plugin-export' 51 | export default defineExportConfig({ 52 | configs: [ 53 | { 54 | targetDir: './src/assets/images', 55 | }, 56 | { 57 | targetDir: './src/assets/css', 58 | outputDir: './src/assets/css', 59 | }, 60 | { 61 | targetDir: './src/assets/svgs', 62 | customImport: (fileName, file) => { 63 | return `import { ReactComponent as ${fileName} } from '${file}'` 64 | }, 65 | }, 66 | ], 67 | }) 68 | 69 | ``` 70 | 71 | Add `vite-plugin-hot-export` plugin to vite.config.js / vite.config.ts and configure it: 72 | 73 | ```js 74 | // vite.config.js / vite.config.ts 75 | import HotExport from 'vite-plugin-hot-export' 76 | 77 | export default { 78 | plugins: [ 79 | HotExport() 80 | ] 81 | } 82 | ``` 83 | Then start your project 84 | ```bash 85 | pnpm run dev 86 | ``` 87 | 88 | ## Author 89 | 90 | sudongyuer email:976499226@qq.com 91 | 92 | ## 📄 License 93 | 94 | [MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer) 95 | -------------------------------------------------------------------------------- /README-zh.md: -------------------------------------------------------------------------------- 1 | [English](https://github.com/sudongyuer/vite-plugin-hot-export#readme) | 简体中文 2 | 3 | # vite-plugin-hot-export 4 | 5 | 自动导出 6 | 7 | [![NPM version](https://badge.fury.io/js/vite-plugin-hot-export.svg)](https://www.npmjs.com/package/vite-plugin-hot-export) 8 | 9 | 10 |

11 | 12 |

13 | 14 | ## 为什么 ? 15 | 16 | 开发时用的image,svg等资源,我们需要手动通过`index.ts`导出, 这款插件就可以解放双手,并且支持`HMR` 🌈 17 | 18 | ## 🚀 特点 19 | 20 | - 👻 支持文件夹批量生成 21 | - 🍁 自动导出文件 22 | - 🐥 自定义输出文件 23 | - 🍄 自定义导入声明 24 | - ✨ 支持`HMR` 25 | - 🌈 支持多级目录 26 | - 🍣 自动添加前缀 27 | 28 | 29 | ## 📺 预览 30 | 31 |

32 | 33 |

34 | 35 | 36 | ## 🦄 用法 37 | 38 | ### 安装 39 | 40 | ```bash 41 | pnpm add -D vite-plugin-hot-export 42 | ``` 43 | 44 | ### 配置 `export.config.ts` 45 | 46 | - `targetDir` (必须) : 目标文件夹 47 | 48 | - `outputDir` (可选,默认:目标文件夹) : 通过 `index.ts` 文件导出 49 | 50 | - `customImport` (可选) : 通过`index.ts`自定义导入 51 | 52 | - `depth` (可选 , 默认: true) : 递归子目录 53 | 54 | - `autoPrefix` (可选 , 默认: false) : 自动给文件加前缀. 注意:如果`customImport`没有配置,则忽略该配置 55 | 56 | ```js 57 | import { defineExportConfig } from 'vite-plugin-hot-export' 58 | export default defineExportConfig({ 59 | configs: [ 60 | { 61 | targetDir: './src/assets/images', 62 | }, 63 | { 64 | targetDir: './src/assets/img', 65 | depth: true, 66 | autoPrefix: true 67 | }, 68 | { 69 | targetDir: './src/assets/css', 70 | outputDir: './src/assets/css', 71 | }, 72 | { 73 | targetDir: './src/assets/svgs', 74 | customImport: (fileName, file) => { 75 | return `import { ReactComponent as ${fileName} } from '${file}'` 76 | }, 77 | }, 78 | { 79 | targetDir: './src/assets/gif', 80 | customImport: (fileName, file, fileType) => { 81 | return `import ${fileType}${fileName} from '${file}'` 82 | }, 83 | depth: true 84 | }, 85 | ], 86 | }) 87 | 88 | ``` 89 | 90 | 增加 `vite-plugin-hot-export` 插件到 vite.config.js / vite.config.ts 然后配置它: 91 | 92 | ```js 93 | // vite.config.js / vite.config.ts 94 | import HotExport from 'vite-plugin-hot-export' 95 | 96 | export default { 97 | plugins: [ 98 | HotExport() 99 | ] 100 | } 101 | ``` 102 | 然后起服务 103 | ```bash 104 | pnpm run dev 105 | ``` 106 | ## 没有生效? 107 | 108 | 如果你用的是`webstorm`,请参考: 109 | 110 | ![image-20220717101450402](https://tva1.sinaimg.cn/large/e6c9d24egy1h49pefcb4jj21580u0wi5.jpg) 111 | 112 | 113 | ## 作者 114 | 115 | sudongyuer email:976499226@qq.com 116 | 117 | ## 📄 License 118 | 119 | [MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer) 120 | -------------------------------------------------------------------------------- /README_zh-cn.md: -------------------------------------------------------------------------------- 1 | # vite-plugin-hot-export 2 | 3 | 自动导出文件并且支持热更新 4 | 5 | [English](/README.md)|简体中文 6 | 7 | [![NPM version](https://badge.fury.io/js/vite-plugin-hot-export.svg)](https://www.npmjs.com/package/vite-plugin-hot-export) 8 | 9 | 10 |

11 | 12 |

13 | 14 | 15 | ## Why ? 16 | 17 | 开发的时候,我们通常需要从网络上下载`图片`或`svg`,使用的时候需要`手动`的在`index.ts`导出,这个插件能够帮助你`自动`导出并且支持热更新 🌈 18 | 19 | ## 🚀 Features 20 | 21 | - 👻 支持多目录生成 22 | - 🍁自动导出文件 23 | - 🐥 自定义导出路径 24 | - 🍄 支持自定义`import`语句 25 | - ✨ 支持热更新 26 | - 🌈 支持嵌套目录生成 27 | - 🍣 支持自动添加前缀 28 | 29 | 30 | ## 📺 Preview 31 | 32 |

33 | 34 |

35 | 36 | 37 | 38 | ## 🦄 Usage 39 | 40 | ### Install 41 | 42 | ```bash 43 | pnpm add -D vite-plugin-hot-export 44 | ``` 45 | 46 | ### Config export.config.ts 47 | 48 | - targetDir(必要的):导出文件的目录 49 | - outputDir (可选的,默认 targetDir) :指定生成`index.ts`的目录 50 | - customImport (可选的):自定义`index.ts`中的导出语句 51 | - depth (可选的 , 默认 true) : 遍历所有子目录 52 | - autoPrefix (可选的 , 默认 false) :自动添加文件前缀名。请注意,如果使用了customImport配置,这个配置将被忽略 53 | 54 | ```js 55 | import { defineExportConfig } from 'vite-plugin-hot-export' 56 | export default defineExportConfig({ 57 | configs: [ 58 | { 59 | targetDir: './src/assets/images', 60 | }, 61 | { 62 | targetDir: './src/assets/img', 63 | depth: true, 64 | autoPrefix: true 65 | }, 66 | { 67 | targetDir: './src/assets/css', 68 | outputDir: './src/assets/css', 69 | }, 70 | { 71 | targetDir: './src/assets/svgs', 72 | customImport: (fileName, file) => { 73 | return `import { ReactComponent as ${fileName} } from '${file}'` 74 | }, 75 | }, 76 | { 77 | targetDir: './src/assets/gif', 78 | customImport: (fileName, file, fileType) => { 79 | return `import ${fileType}${fileName} from '${file}'` 80 | }, 81 | depth: true 82 | }, 83 | ], 84 | }) 85 | 86 | ``` 87 | 88 | 在vite.config.js / vite.config.ts中添加 `vite-plugin-hot-export`插件并且配置: 89 | 90 | ```js 91 | // vite.config.js / vite.config.ts 92 | import HotExport from 'vite-plugin-hot-export' 93 | 94 | export default { 95 | plugins: [ 96 | HotExport() 97 | ] 98 | } 99 | ``` 100 | 101 | 在你的项目中使用 102 | 103 | ```bash 104 | pnpm run dev 105 | ``` 106 | 107 | ## Not Work? 108 | 109 | 如果你使用的是webstorm,请按照下面的步骤检查: 110 | 111 | ![image-20220717101450402](https://tva1.sinaimg.cn/large/e6c9d24egy1h49pefcb4jj21580u0wi5.jpg) 112 | 113 | 114 | ## Author 115 | 116 | sudongyuer email:976499226@qq.com 117 | 118 | ## 📄 License 119 | 120 | [MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer) 121 | -------------------------------------------------------------------------------- /packages/vite-plugin-hot-export/src/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import { cwd } from 'process' 3 | import child_process from 'child_process' 4 | import fs from 'fs' 5 | import type { Plugin } from 'vite' 6 | import { loadConfig } from 'unconfig' 7 | import chokidar from 'chokidar' 8 | import { main } from 'auto-export/utils' 9 | function VitePluginHotExport(): Plugin { 10 | return { 11 | name: 'vite-plugin-hot-export', 12 | apply: 'serve', 13 | config(config, { command }) { 14 | excuteAutoExport() 15 | if (command === 'serve') { 16 | loadConfig({ 17 | sources: [ 18 | { 19 | files: 'export.config', 20 | extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json', ''], 21 | }, 22 | ], 23 | }).then(({ config: configArray }) => { 24 | const configs = configArray.configs 25 | for (let i = 0; i < configs.length; i++) { 26 | const config = configs[i] 27 | // const { targetDir, outputDir } = config 28 | // let filesCount = getCurrentDirFilesCount(targetDir) 29 | chokidar.watch(path.resolve(cwd(), config.targetDir), { 30 | ignoreInitial: true, 31 | atomic: true, 32 | followSymlinks: true, 33 | }).on('all', (event, pathDir) => { 34 | if (!pathDir.includes('index')) { 35 | // const newFilesCount = getCurrentDirFilesCount(targetDir) 36 | // if (newFilesCount !== filesCount) { 37 | excuteAutoExport() 38 | // filesCount = newFilesCount 39 | // } 40 | } 41 | }) 42 | } 43 | }) 44 | } 45 | }, 46 | } 47 | } 48 | 49 | function excuteAutoExport() { 50 | try { 51 | main() 52 | } 53 | catch (error) { 54 | child_process.execSync('npx autoexport') 55 | } 56 | } 57 | 58 | type CustomImport = (fileName: string, file: string, fileType: string) => string 59 | 60 | interface Config { 61 | targetDir: string 62 | outputDir?: string 63 | customImport?: CustomImport 64 | depth?: boolean 65 | autoPrefix?: boolean 66 | } 67 | 68 | export interface ExportConfig { 69 | configs: Array 70 | } 71 | 72 | function defineExportConfig(config: ExportConfig): ExportConfig { 73 | return config 74 | } 75 | 76 | function getCurrentDirFilesCount(targetDir: string) { 77 | let filesLength = 0 78 | const DirAndFiles = fs.readdirSync(path.resolve(cwd(), targetDir)) 79 | for (let i = 0; i < DirAndFiles.length; i++) { 80 | const file = DirAndFiles[i] 81 | const filePath = path.resolve(cwd(), targetDir, file) 82 | const stats = fs.statSync(filePath) 83 | if (stats.isFile()) 84 | filesLength++ 85 | else 86 | filesLength += getCurrentDirFilesCount(filePath) 87 | } 88 | return filesLength 89 | } 90 | 91 | export { defineExportConfig } 92 | 93 | export default VitePluginHotExport 94 | -------------------------------------------------------------------------------- /packages/client/src/svgs/cassette-hipster-music.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/client/src/svgs/bow-fashion-hipster.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/client/src/svgs/hipster-music-on-trend.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vite-plugin-hot-export 2 | 3 | 4 | 5 | Automatically export files with HMR 6 | 7 | English|[简体中文](/README_zh-cn.md) 8 | 9 | [![NPM version](https://badge.fury.io/js/vite-plugin-hot-export.svg)](https://www.npmjs.com/package/vite-plugin-hot-export) 10 | 11 | 12 |

13 | 14 |

15 | 16 | ## Why ? 17 | 18 | When developing, we often need to download some `images` or `svg` from the internet, and when we need to use them, we need export them in `index.ts` file `manually`, this plugin can handle this for you `automatically`.And support HMR 🌈 19 | 20 | ## 🚀 Features 21 | 22 | - 👻 Multiple directory generate support 23 | - 🍁 Auto export files 24 | - 🐥 custom outputDir 25 | - 🍄 Support custom import statement 26 | - ✨ HMR support 27 | - 🌈 Nest directory generate support 28 | - 🍣 Auto Prefix support 29 | 30 | 31 | ## 📺 Preview 32 | 33 |

34 | 35 |

36 | 37 | 38 | ## 🦄 Usage 39 | 40 | ### Install 41 | 42 | ```bash 43 | pnpm add -D vite-plugin-hot-export 44 | ``` 45 | 46 | ### Config `export.config.ts` 47 | 48 | - targetDir (require) : the directory to export files 49 | 50 | - outputDir (optional,default targetDir) : the directory to generate the `index.ts` file to export files 51 | 52 | - customImport (optional) : custom the import statement to use in the `index.ts` file 53 | 54 | - depth (optional , default true) : traverse all subdirectories 55 | 56 | - autoPrefix (optional , default false) : auto add prefix to the file name. Note that the if you open the customImport option,this option will be ignored 57 | 58 | ```js 59 | import { defineExportConfig } from 'vite-plugin-hot-export' 60 | export default defineExportConfig({ 61 | configs: [ 62 | { 63 | targetDir: './src/assets/images', 64 | }, 65 | { 66 | targetDir: './src/assets/img', 67 | depth: true, 68 | autoPrefix: true 69 | }, 70 | { 71 | targetDir: './src/assets/css', 72 | outputDir: './src/assets/css', 73 | }, 74 | { 75 | targetDir: './src/assets/svgs', 76 | customImport: (fileName, file) => { 77 | return `import { ReactComponent as ${fileName} } from '${file}'` 78 | }, 79 | }, 80 | { 81 | targetDir: './src/assets/gif', 82 | customImport: (fileName, file, fileType) => { 83 | return `import ${fileType}${fileName} from '${file}'` 84 | }, 85 | depth: true 86 | }, 87 | ], 88 | }) 89 | 90 | ``` 91 | 92 | Add `vite-plugin-hot-export` plugin to vite.config.js / vite.config.ts and configure it: 93 | 94 | ```js 95 | // vite.config.js / vite.config.ts 96 | import HotExport from 'vite-plugin-hot-export' 97 | 98 | export default { 99 | plugins: [ 100 | HotExport() 101 | ] 102 | } 103 | ``` 104 | Then start your project 105 | ```bash 106 | pnpm run dev 107 | ``` 108 | ## Not Work? 109 | 110 | If you are use webstorm, please check the following: 111 | 112 | ![image-20220717101450402](https://tva1.sinaimg.cn/large/e6c9d24egy1h49pefcb4jj21580u0wi5.jpg) 113 | 114 | 115 | ## Author 116 | 117 | sudongyuer email:976499226@qq.com 118 | 119 | ## 📄 License 120 | 121 | [MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer) 122 | -------------------------------------------------------------------------------- /packages/client/src/svgs/headphones-hipster-music.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------