Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jwyGithub/rsbuild-plugin-auto-alias
automatically generate alias based on path
https://github.com/jwyGithub/rsbuild-plugin-auto-alias
Last synced: about 2 months ago
JSON representation
automatically generate alias based on path
- Host: GitHub
- URL: https://github.com/jwyGithub/rsbuild-plugin-auto-alias
- Owner: jwyGithub
- License: mit
- Created: 2024-11-11T01:13:14.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-11-11T06:31:17.000Z (2 months ago)
- Last Synced: 2024-11-11T06:31:34.460Z (2 months ago)
- Language: TypeScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rspack - rsbuild-plugin-auto-alias
README
# rsbuild-plugin-auto-alias
automatically generate alias based on path
## Features
- Support for custom alias prefixes
- Supports synchronous mode configuration## Install
#### pnpm
```sh
pnpm add rsbuild-plugin-auto-alias -D
```#### yarn
```sh
yarn add rsbuild-plugin-auto-alias -D
```#### npm
```sh
npm install rsbuild-plugin-auto-alias -D
```## Use
> rsbuild.config.ts / rsbuild.config.js
```typescript
import { defineConfig } from '@rsbuild/core';
import { pluginAutoAlias } from 'rsbuild-plugin-auto-alias';export default defineConfig({
plugins: [pluginAutoAlias({})]
});
```## Option
```typescript
export interface AutoAlias {
/**
* @description the root directory where the alias needs to be generated is src by default
* @default src
*/
root?: string;/**
* @description prefix for generating aliases
* @default @
*/
prefix?: string;/**
* @description synchronize the mode of json configuration
* @default all
*/
mode?: 'sync' | 'off';/**
* @description alias configuration file path
* @default tsconfig.json
*/
aliasPath?: string;
}
```> tsconfig.json / jsconfig.json
```json
{
"compilerOptions": {
"baseUrl": "./"
// ...
}
}
```## Example
|-- src
|-- plugins
|-- router
|-- scss
|-- store
|-- utils
|-- views
|-- ....```typescript
import xxx from '@plugins/xxx';
import xxx from '@router/xxx';
import xxx from '@scss/xxx';
import xxx from '@store/xxx';
import xxx from '@utils/xxx';
import xxx from '@views/xxx';
```