Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/holy-two/vite-plugin-alias
alias from ts.config.json
https://github.com/holy-two/vite-plugin-alias
Last synced: 9 days ago
JSON representation
alias from ts.config.json
- Host: GitHub
- URL: https://github.com/holy-two/vite-plugin-alias
- Owner: holy-two
- License: apache-2.0
- Created: 2024-01-20T19:32:32.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-03T22:23:24.000Z (10 months ago)
- Last Synced: 2024-10-31T18:29:35.877Z (18 days ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@holy-two/vite-plugin-alias
- Size: 73.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @holy-two/vite-plugin-alias
![@holy-two/vite-plugin-alias](https://img.shields.io/npm/v/@holy-two/vite-plugin-alias.svg)
## Illustration
This is a vite plugin that automatically retrieves and sets path aliases from [`tsconfig.json`](./playground/tsconfig.json).
## Usage
```shell
npm i @holy-two/vite-plugin-alias -D
```In `vite.config.ts`:
```diff
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
+ import vitePluginTemplate from '@holy-two/vite-plugin-alias'export default defineConfig({
plugins: [vue(),
+ vitePluginTemplate(),
],
})```
You just need to configure it like this in `tsconfig.json`:
```diff
{
"extends": "../tsconfig.json",
"compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "~/*": [
+ "src/*"
+ ]
+ }
},
"include": [
"src/**/*.vue",
"src/**/*.ts",
"vite.config.ts"
],
}
````@holy-two/vite-plugin-alias` will automatically parse the paths set within the paths to define aliases.
So you can use `~/components/**` (same as `./src/components/**`) to access files.