Skip to content

hunghg255/vite-host-qrcode

Repository files navigation

logo

A plugin print text, QR code for Vitejs

NPM Version NPM Downloads Minizip Contributors License

Install

npm i vite-host-qrcode -D
# package.json
"scripts": {
  "dev": "vite --host",
  ...
},
Vite
// vite.config.ts
import HostQrCode from 'vite-host-qrcode/vite'

export default defineConfig({
  plugins: [
    HostQrCode({ /* options */ }),
  ],
})

Example: playground/


CLI output

Options

type Message = string | MessageValue | ((kolorist: Kolorist) => string | MessageValue | Promise<string | MessageValue | void>)

export interface Options {
	info?: Message[]
  /**
	 * filter list of shown QR codes. Useful if you have multiple interfaces and only need one
	 *
	 *  examples:
	 *    url => url.startsWith('http://192.')
	 *    url => !url.startsWith('http://172.)
	 *    url => url === 'http://192.168.1.70:4173'
	 *
	 * @param url {string} ip address
	 * @returns {boolean}
	 */
  filter?: (url: string) => boolean
}

filter

A function that allows you to select addresses to show QR-Codes for in case you have multiple interfaces

Example:

// vite.config.js
import HostQrCode from 'vite-host-qrcode/vite'

export default defineConfig({
	plugins: [HostQrCode({ filter: (url) => url === 'http://192.168.1.1:4173' })]
});

About

Run Vite host with qrcode

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published