@bolinjs/vite-plugin-log-label
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

Vite Plugin Log Label

A Vite plugin that replaces _log() with styled console.log outputs during compilation and provides type declarations.

Install

pnpm i -D @bolinjs/vite-plugin-log-label
// vite.config.js
import LogLabel from '@bolinjs/vite-plugin-log-label'

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

如果要配合uniapp的日志回显,需要放在uni插件之前

// vite.config.js
import LogLabel from '@bolinjs/vite-plugin-log-label'

export default {
  plugins: [
    LogLabel({
      /* options */
    }),
    uni(),
  ],
}

Configuration

LogLabel({
  // Filepath to generate corresponding .d.ts file.
  // Defaults to './log-label.d.ts' when `typescript` is installed locally.
  // Set `false` to disable.
  dts: './log-label.d.ts',

  // log function name to be replaced
  identifier: '_log',

  // themes
  // usage: _log.theme()
  theme: {
    // preset
    default: `background-image: linear-gradient(to right, #92fe9d 0%, #00c9ff 100%);color:#000;padding:2px 5px;border-radius:4px;`,
    info: ['#165DFF', '#fff'],
    success: ['#00B42A', '#fff'],
    warn: ['#FF7D00', '#fff'],
    error: ['#F53F3F', '#fff'],
    // custom
    custom: ['white', 'black'],
  },
})

Usage

_log(any)
_log.default(any)
_log.info(any)
_log.success(any)
_log.warn(any)
_log.error(any)
_log.custom(any)
_log['pink,#000'](any)

Package Sidebar

Install

npm i @bolinjs/vite-plugin-log-label

Weekly Downloads

13

Version

1.2.4

License

MIT

Unpacked Size

21.6 kB

Total Files

8

Last publish

Collaborators

  • bolinjs