1.0.0 • Published 1 year ago

vite-plugin-data-url v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vite-plugin-data-url

npm npm GitHub

Add support for data-url query import, you can directly import the data-url address of the image.

📦 Install

npm i vite-plugin-data-url -D

# yarn
yarn add vite-plugin-data-url -D

# pnpm
pnpm add vite-plugin-data-url -D

🦄 Usage

Add envParse plugin to vite.config.js / vite.config.ts and configure it:

// vite.config.js / vite.config.ts
import { dataUrl } from 'vite-plugin-data-url'

export default {
  plugins: [dataUrl()]
}

Typescript

Add types for ?data-url

"complierOptions":{
  // ...
  "types": ["vite-plugin-data-url/types"]
  // ...
}

API

Base64ImportOptions

Property NameTypeDescriptionDefault Value
sizeWarningbooleanWhether to disable the warning when specified files exceed the set size limit.true
limitnumberThe maximum file size (in KB) for converting to base64. If exceeded, a warning will be given and the file will be ignored.10 * 1024

License

MIT licenses