https://github.com/unplugin/unplugin-printer
✨ Print beautiful info in the terminal
https://github.com/unplugin/unplugin-printer
Last synced: 7 months ago
JSON representation
✨ Print beautiful info in the terminal
- Host: GitHub
- URL: https://github.com/unplugin/unplugin-printer
- Owner: unplugin
- License: mit
- Created: 2023-08-31T06:00:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-31T14:26:18.000Z (over 2 years ago)
- Last Synced: 2025-06-21T03:09:59.525Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 367 KB
- Stars: 31
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# unplugin-printer
## Install
```bash
npm i unplugin-printer
```
## Features
- User-friendly options
- Customizable styles
- Supports async functions
## Options
`unplugin-printer` uses [kolorist](https://github.com/marvinhagemeister/kolorist) and [boxen](https://github.com/sindresorhus/boxen) to customize the text color and style of the output. You can refer to the documentation to explore the available options in detail.
```ts
import type * as kolorist from 'kolorist'
import type { Options as BoxenOptions } from 'boxen'
type Kolorist = typeof kolorist
type MessageValue = BoxenOptions & { text: string }
type Message = string | MessageValue | ((kolorist: Kolorist) => string | MessageValue | Promise)
interface Options {
info: Message[]
}
```
## Usage
```ts
// vite.config.ts
import Printer from 'unplugin-printer/vite'
export default defineConfig({
plugins: [
Printer({
info: [
// 1. use string value
'Hello World',
// 2. use object to customize the style
{ text: 'Hello World', padding: 1, margin: 1, borderColor: 'green' },
// 3. use function to customize the text color and style
(kolorist) => {
return {
text: kolorist.yellow('Hello World'),
padding: 1,
margin: 1,
}
},
// 4. use with async function
async (kolorist) => {
const text = await fetch('https://api.github.com/repos/unplugin/unplugin-printer')
.then(res => res.json())
.then(res => res.description)
return {
text: kolorist.yellow(text),
padding: 1,
margin: 1,
}
},
]
}),
],
})
```
Vite
```ts
// vite.config.ts
import Printer from 'unplugin-printer/vite'
export default defineConfig({
plugins: [
Printer({ /* options */ }),
],
})
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-printer/webpack')({ /* options */ })
]
}
```
Nuxt
```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-printer/nuxt', { /* options */ }],
],
})
```
> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
Vue CLI
```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-printer/webpack')({ /* options */ }),
],
},
}
```
## License
MIT License © 2023-PRESENT [webfansplz](./LICENSE)