Skip to content

Add additional customized shortcut key population for vite4. If the current version of vite does not support shortcut keys, add the shortcut key function

License

Notifications You must be signed in to change notification settings

kinfuy/vite-plugin-shortcuts

Repository files navigation

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


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

About

Add additional customized shortcut key population for vite4. If the current version of vite does not support shortcut keys, add the shortcut key function

Resources

License

Stars

Watchers

Forks

Packages

No packages published