
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
vite-plugin-binary
Advanced tools
A Vite plugin for importing the file as binary with compress support.
npm i -D vite-plugin-binary
vite.config.ts
import { defineConfig } from 'vite'
import Binary from 'vite-plugin-binary'
export default defineConfig({
plugins: [Binary()],
})
// main.ts
import compressed from './opposans.ttf?binary'
This plugin will compress the imported file in gzip format by default. This will slightly reduce the final js file size.
If you don't want this feature. You can disable it by setting in vite.config.ts.
import { defineConfig } from 'vite'
import Binary from 'vite-plugin-binary'
export default defineConfig({
plugins: [Binary({ gzip: false })],
})
Given the imports is compressed in gzip format. You can decompress by using the zlib no Node.js environment.
import { gunzipSync } from 'node:zlib'
import compressed from './opposans.ttf?binary'
const uint8Array = gzipSync(compressed)
Given the imports is compressed in gzip format. You can install fflate and other tools.
npm i fflate
import { gunzipSync } from 'fflate'
import compressed from './opposans.ttf?binary'
const uint8Array = gzipSync(compressed)
To add the types check support for using typescript. Modify the tsconfig.json file as follows.
{
"compilerOptions": {
"types": ["vite-plugin-binary/types"]
}
}
FAQs
Vite plugin for importing file in Uint8Array format
We found that vite-plugin-binary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.