Skip to content

Latest commit

 

History

History
50 lines (42 loc) · 804 Bytes

README.md

File metadata and controls

50 lines (42 loc) · 804 Bytes

vite-plugin-server-callback

It is a plugin to get exact listened port on vite.

Install

npm install vite-plugin-server-callback -D

yarn add vite-plugin-server-callback -D

Usage

import { defineConfig } from 'vite';
import serverPlugin from 'vite-plugin-server-callback'

export default defineConfig({
  ...,
  plugins:[
    serverPlugin({
      onReady: (port: number) => {
        console.log("onReady", port)
      }
    })
  ]
})

onError

emit error on http server

import { defineConfig } from 'vite';
import serverPlugin from 'vite-plugin-server-callback'

export default defineConfig({
  ...,
  plugins:[
    serverPlugin({
      onError: (err: Error) => {
        console.error("err", err)
      }
    })
  ]
})

onClose

//