{"id":17354055,"url":"https://github.com/forinda/react-vite-alias","last_synced_at":"2026-05-11T02:27:49.958Z","repository":{"id":103065305,"uuid":"596362299","full_name":"forinda/react-vite-alias","owner":"forinda","description":"An implementation of vite alias on your react application to avoid long imports and have aliased imports","archived":false,"fork":false,"pushed_at":"2023-02-02T02:35:50.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T17:44:09.444Z","etag":null,"topics":["imports","module-alias","react","react-aliases","typescript-aliases","typescript-module","vite","vite-aliases","vitejs","vitejs-react","vitejs-react-typescript"],"latest_commit_sha":null,"homepage":"","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/forinda.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-02T02:28:40.000Z","updated_at":"2024-03-30T18:52:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f3b6913-b8df-4f88-bd76-56f234c840df","html_url":"https://github.com/forinda/react-vite-alias","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/forinda%2Freact-vite-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forinda%2Freact-vite-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forinda%2Freact-vite-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forinda%2Freact-vite-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forinda","download_url":"https://codeload.github.com/forinda/react-vite-alias/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245851308,"owners_count":20682826,"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":["imports","module-alias","react","react-aliases","typescript-aliases","typescript-module","vite","vite-aliases","vitejs","vitejs-react","vitejs-react-typescript"],"created_at":"2024-10-15T17:18:51.053Z","updated_at":"2026-05-11T02:27:49.931Z","avatar_url":"https://github.com/forinda.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rect-vite-alias\nAn implementation of vite alias on your react application to avoid long imports and have aliased imports\n\nAt first I thought this was hard but vite simplifies everything\n\nJust add everything to your `tsconfig.json`\n```tsx\n{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@pages/*\": [\"src/pages/*\"],\n      \"@components/*\": [\"src/components/*\"],\n      \"@router\": [\"src/router\"]\n    },\n    ...\n  },\n  \"include\": [\"src\"],\n  \"references\": [{ \"path\": \"./tsconfig.node.json\" }]\n}\n```\n\nAfterwards have a replication of the same for `rollup` to know in this format in your `vite.config.ts`\n```tsx\nimport { defineConfig } from \"vite\";\nimport path from \"path\";\nimport react from \"@vitejs/plugin-react-swc\";\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [react()],\n  resolve: {\n    alias: {\n    \"@pages\": path.resolve(__dirname, \"src/pages\"),\n    \"@components\": path.resolve(__dirname, \"src/components\"),\n    \"@router\": path.resolve(__dirname, \"src/router\"),\n    }}\n});\n```\n\nJust by this now you've simplified your code to this kind of imports\n```tsx\nimport Header from \"@components/Header\";\nimport About from \"@pages/About\";\nimport Contact from \"@pages/Contact\";\nimport Home from \"@pages/Home\";\n```\nInstead of \n```\nimport Header from \"./../components/Header\";\nimport About from \"./../pages//About\";\nimport Contact from \"./../pages//Contact\";\nimport Home from \"./../pages//Home\";\n```\n\nThis is the easiest implementation I have ever seen :rocket:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforinda%2Freact-vite-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforinda%2Freact-vite-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforinda%2Freact-vite-alias/lists"}