Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kinfuy/vite-plugin-shortcuts
Add additional customized shortcut key population for vite4. If the current version of vite does not support shortcut keys, add the shortcut key function
https://github.com/kinfuy/vite-plugin-shortcuts
Last synced: 3 months ago
JSON representation
Add additional customized shortcut key population for vite4. If the current version of vite does not support shortcut keys, add the shortcut key function
- Host: GitHub
- URL: https://github.com/kinfuy/vite-plugin-shortcuts
- Owner: kinfuy
- License: mit
- Created: 2022-12-30T03:47:00.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T16:21:48.000Z (11 months ago)
- Last Synced: 2024-10-12T17:55:21.088Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 713 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-zh_CN.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-vite - vite-plugin-shortcuts - Add additional customized shortcut key population. (Plugins / Framework-agnostic Plugins)
- awesome-vite - vite-plugin-shortcuts - Add additional customized shortcut key population. (Plugins / Framework-agnostic Plugins)
README
# vite-plugin-shortcuts
为 vite4 添加额外自定义快捷键人口,如果 vite 当前版本不支持快捷键,则添加快捷键功能
简体中文 | [English](./README.md)
## Demo
### vite4
![vite4](https://user-images.githubusercontent.com/37766068/235663282-c94f23d9-cb84-429b-94e1-625620bc1b01.png)
### vite3
![vite3](https://user-images.githubusercontent.com/37766068/235663330-8d416b95-c4e4-4824-8086-a653d62f6a42.png)
### vite2
![vite2](https://user-images.githubusercontent.com/37766068/235663376-9a56c8e7-994e-48e9-b175-a7722dc7d94e.png)
## Installation
```sh
pnpm add vite-plugin-shortcuts
```## Usage
```ts
import { defineConfig } from 'vite';
import { shortcutsPlugin } from 'vite-plugin-shortcuts';export default defineConfig({
plugins: [
shortcutsPlugin({
shortcuts: [
{
key: 'c',
description: 'close console',
action: (server) => {
server.config.logger.clearScreen('error');
},
},
{
key: 's',
description: 'reset console',
action: (server) => {
server.config.logger.clearScreen('error');
server.printUrls();
},
},
// {
// key: 'r',
// description: 'restart the server',
// async action(server) {
// await server.restart();
// },
// },
// {
// key: 'u',
// description: 'show server url',
// action(server) {
// server.config.logger.info('');
// server.printUrls();
// },
// },
// {
// key: 'q',
// description: 'quit',
// async action(server) {
// await server.close().finally(() => process.exit());
// },
// },
],
}),
],
});
```