Skip to content

Latest commit

 

History

History
85 lines (70 loc) · 1.97 KB

README-zh_CN.md

File metadata and controls

85 lines (70 loc) · 1.97 KB

vite-plugin-shortcuts

为 vite4 添加额外自定义快捷键人口,如果 vite 当前版本不支持快捷键,则添加快捷键功能


简体中文 | English

Demo

vite4

vite4

vite3

vite3

vite2

vite2

Installation

pnpm add vite-plugin-shortcuts

Usage

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());
        //   },
        // },
      ],
    }),
  ],
});