🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

vite-plugin-run

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-run

Runner plugin for Vite

0.6.1
latest
Source
npm
Version published
Weekly downloads
4.9K
-29.31%
Maintainers
1
Weekly downloads
 
Created
Source

Runner plugin for Vite

version

A plugin for running commands when files change or when Vite starts.

npm i -D vite-plugin-run

 

Usage

Install vite-plugin-run and add it to your Vite configuration:

import { run } from 'vite-plugin-run'

export default defineConfig({
  plugins: [
    laravel(),
      vue(),
      run([
        {
          name: 'typescript transform',
          run: ['php', 'artisan', 'typescript:transform'],
          pattern: ['app/**/*Data.php', 'app/**/Enums/**/*.php'],
        },
        {
          name: 'build routes',
          run: ['php', 'artisan', 'routes:generate'],
          condition: (file) => file.includes('/routes/'),
        }
      ]),
  ],
})

You can either use a pattern or a condition to specify how the files changes should be detected.

When a file in your project changes, its path will be given as an argument to condition. If the function returns true, a shell command described by run will be executed.

 

Plugin options

OptionTypeDescriptionDefault
silentboolWhether to hide the commands output in the consoletrue
skipDtsboolWhether to skip HMR reloads when a .d.ts file changestrue
inputRunner[]List of runners[]

Optionally, you can directly pass a runner or a list of runner to the plugin options.

 

Runner options

OptionTypeDescriptionDefault
startupboolWhether the command should run when Vite startstrue
buildboolWhether the command should run when Vite buildstrue
namestringAn identifier for the runner, used in logs
condition() => booleanA function that should return true for a file change to execute the runner
patternstring or string[]A minimatch pattern which files must match
run() => string[] or string[]A command executed when a file changed and the condition matches
onFileChanged() =>voidA callback executed when a file changed and the condition matches
delaynumberDelay before the command is executed50
throttlenumberDelay before the command can be re-executed50



·

Built with ❤︎ by Enzo Innocenzi

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts