Created
March 25, 2022 11:04
-
-
Save myobie/9fd12cd3cdc32f6c613a154b249ea640 to your computer and use it in GitHub Desktop.
Generate Blob import from file on disk with deno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bytes = await Deno.readFile(new URL('./thumbnail.png', import.meta.url)) | |
const encoder = new TextEncoder() | |
const contents = encoder.encode( | |
`export const thumbnail = new Blob(new Uint8Array(${ | |
JSON.stringify(Array.from(bytes)) | |
}), { type: 'image/png' })` | |
) | |
await Deno.writeFile(new URL('./hardcoded-thumbnail.ts', import.meta.url), contents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment