{"id":13417440,"url":"https://github.com/jwyGithub/vite-plugin-auto-alias","last_synced_at":"2025-03-15T02:31:22.889Z","repository":{"id":55292870,"uuid":"234317055","full_name":"jwyGithub/vite-plugin-auto-alias","owner":"jwyGithub","description":"automatically generate alias based on path","archived":false,"fork":false,"pushed_at":"2024-10-15T03:28:39.000Z","size":1453,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-30T00:44:09.039Z","etag":null,"topics":["alias","vite"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vite-plugin-auto-alias","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/jwyGithub.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2020-01-16T12:39:55.000Z","updated_at":"2024-10-15T03:28:43.000Z","dependencies_parsed_at":"2024-01-07T18:05:31.264Z","dependency_job_id":"3fae2452-f359-469f-a5c2-7bdc8524bf73","html_url":"https://github.com/jwyGithub/vite-plugin-auto-alias","commit_stats":{"total_commits":106,"total_committers":3,"mean_commits":"35.333333333333336","dds":"0.13207547169811318","last_synced_commit":"23a81a6a686f5c0a3736574f460d529df081c8fe"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Fvite-plugin-auto-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Fvite-plugin-auto-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Fvite-plugin-auto-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Fvite-plugin-auto-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwyGithub","download_url":"https://codeload.github.com/jwyGithub/vite-plugin-auto-alias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243674847,"owners_count":20329173,"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":["alias","vite"],"created_at":"2024-07-30T22:00:37.265Z","updated_at":"2025-03-15T02:31:22.580Z","avatar_url":"https://github.com/jwyGithub.png","language":"TypeScript","readme":"English | [简体中文](https://github.com/jwyGithub/vite-plugin-auto-alias/blob/master/README.zh.md)\n\n# vite-plugin-auto-alias\n\nautomatically generate alias based on path\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/vite-plugin-auto-alias\" alt='version'\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dm/vite-plugin-auto-alias\" alt='download'\u003e\n  \u003cimg src=\"https://img.shields.io/github/issues/jwyGithub/vite-plugin-auto-alias\" alt='issues'\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/jwyGithub/vite-plugin-auto-alias\" alt='license'\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n## Features\n\n-   Support for hot updates\n-   Support for custom alias prefixes\n-   Supports synchronous mode configuration\n\n## Install\n\n#### pnpm\n\n```sh\npnpm add vite-plugin-auto-alias -D\n```\n\n#### yarn\n\n```sh\nyarn add vite-plugin-auto-alias -D\n```\n\n#### npm\n\n```sh\nnpm install vite-plugin-auto-alias -D\n```\n\n## Use\n\n\u003e vite.config.ts / vite.config.js\n\n```typescript\nimport autoAlias from 'vite-plugin-auto-alias';\n\nexport default defineConfig(({ command, mode }) =\u003e {\n    return {\n        plugins: [autoAlias()]\n    };\n});\n```\n\n## Option\n\n```typescript\nexport interface AutoAlias {\n    /**\n     * @description the root directory where the alias needs to be generated is src by default\n     * @default src\n     */\n    root?: string;\n\n    /**\n     * @description prefix for generating aliases\n     * @default @\n     */\n    prefix?: string;\n\n    /**\n     * @description synchronize the mode of json configuration\n     * @default all\n     */\n    mode?: 'sync' | 'off';\n\n    /**\n     * @description alias configuration file path\n     * @default tsconfig.json\n     */\n    aliasPath?: string;\n}\n```\n\n#### Mode\n\n-   sync : when use `sync`,the plugin will search for `tsconfig.json` or `jsconfig.json` in the root directory of the current project, so please ensure that this file exists in the project. The plugin will automatically generate paths options when running, and then write them to the file without the need for developers to manually add them\n\n\u003e vite.config.ts / vite.config.js\n\n```typescript\nimport autoAlias from 'vite-plugin-auto-alias';\n\nexport default defineConfig(({ command, mode }) =\u003e {\n    return {\n        plugins: [\n            autoAlias({\n                // ...\n                mode: 'sync'\n            })\n        ]\n    };\n});\n```\n\n\u003e tsconfig.json / jsconfig.json\n\n```json\n{\n    \"compilerOptions\": {\n        \"baseUrl\": \"./\"\n        // ...\n    }\n}\n```\n\n## Example\n\n    |-- src\n        |-- plugins\n        |-- router\n        |-- scss\n        |-- store\n        |-- utils\n        |-- views\n        |-- ....\n\n```typescript\nimport xxx from '@plugins/xxx';\nimport xxx from '@router/xxx';\nimport xxx from '@scss/xxx';\nimport xxx from '@store/xxx';\nimport xxx from '@utils/xxx';\nimport xxx from '@views/xxx';\n```\n","funding_links":[],"categories":["Plugins","vite"],"sub_categories":["Framework-agnostic Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjwyGithub%2Fvite-plugin-auto-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FjwyGithub%2Fvite-plugin-auto-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjwyGithub%2Fvite-plugin-auto-alias/lists"}