0.6.0 • Published 9 months ago

vite-plugin-run v0.6.0

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

 

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
0.6.0

9 months ago

0.5.2

1 year ago

0.5.0

2 years ago

0.5.1

2 years ago

0.3.0

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago