Skip to content

Commit abd3007

Browse files
committed
add webpack prior art
1 parent 15f1e1a commit abd3007

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ Bun 1.1.5 added a similar feature in [April 2024](https://bun.sh/blog/bun-v1.1.5
9595
import html from "./index.html" with { type: "text" };
9696
```
9797

98+
Webpack has [asset modules](https://webpack.js.org/guides/asset-modules/) to inline a data URI via [url-loader](https://www.npmjs.com/package/url-loader) and now `asset/inline`.
99+
100+
```js
101+
import logo from './images/logo.svg';
102+
block.style.background = url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDo...vc3ZnPgo=)
103+
```
104+
98105
### What about ArrayBuffer vs Uint8Array?
99106

100107
Both are viable solutions. Uint8Array matches the [Response.bytes()](https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes) method return type as well as [Deno's implementation](https://deno.com/blog/v2.4#importing-text-and-bytes). Uint8Array is also compatible with [Node.js Buffer](https://nodejs.org/api/buffer.html#buffer) which makes it widely compatible with existing JavaScript code.

0 commit comments

Comments
 (0)