New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vite-plugin-import-buffer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-import-buffer

Import files as node Buffers

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

vite-plugin-import-buffer

This vite/rollup plugin allows importing files as node Buffers. Files are appropriately emitted into build outputs, and loaded as a Buffer automatically.

Usage

import { defineConfig } from 'vite'
import importBuffer from 'vite-plugin-import-buffer'

export default defineConfig({
  plugins: [
    importBuffer()
  ]
})

Example

import fontData from './Inter-Regular.ttf?buffer';

Options

include

Type: string[] | RegExp

Default: []

Glob patterns or RegExp to include files.

exclude

Type: string[] | RegExp

Default: []

Glob patterns or RegExp to exclude files.

loader

Type: (src: string) => string

Default: (src) => import { readFile } from 'node:fs/promises'; export const originalUrl = ${src}; const buf = await readFile(new URL(originalUrl, import.meta.url)); export default buf;`

A function that returns the loader code for the buffer.

License

MIT

Keywords

vite

FAQs

Package last updated on 21 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts