1.0.0 • Published 4 months ago

vite-plugin-command v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Vite Command Runner

A Vite plugin that runs custom shell commands on file changes.

Installation

You can install the package via npm:

npm i -D vite-plugin-command

Usage

Import the package from vite.config.js and configure it.

import { defineConfig } from "vite"
import { command } from "vite-plugin-command"

export default defineConfig({
  plugins: [ 
    command({
      pattern: "routes/**/*.php",
      run: "php artisan ziggy:generate",
    }),
  ],
})

You can also run multiple commands by passing an array of objects.

export default defineConfig({
  plugins: [ 
    command([
      {
        pattern: "routes/**/*.php",
        run: "php artisan ziggy:generate",
      },
      {
        pattern: "app/{Data,Enums}/**/*.php",
        run: "php artisan typescript:transform",
      },
    ]),
  ],
})

Once a tracked file changes, the plugin will execute the specified command.

Plugin options

nametypedescriptiondefault
patternstring or string[]Tracked files paths (minimatch pattern)
runstringThe command to be executed
silentbooleanHide the command output in the consolefalse
throttlenumberDelay before the command can be re-executed (in milliseconds)500
startupbooleanRun the command when Vite startstrue
customOutputstring or (output) => stringDisplay a custom output in the console after command ran (when set, the command output will be hidden)

License

The MIT License (MIT). Please see License File for more information.

1.0.0

4 months ago

0.0.4

4 months ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago