📀 ArrayBuffer loader for webpack
- Modern Browsers (IE >= 10)
- Node.js
$ yarn add arraybuffer-loader
or
$ npm install arraybuffer-loader --save-dev
If you read only the specific extensions (e.g. wasm), please add loader in webpack.config.js
.
module: {
rules: [
{
test: /\.png$/,
loaders: ['arraybuffer-loader'],
},
],
},
Or if reading an arbitrary extension, use require
.
const buffer = require('arraybuffer!./data.dat')
const array = new Uint8Array(buffer)
See also offical document Loaders.
Webpack 4 or later has embedded WASM parser. So, please set type: 'javascript/auto'
when use arraybuffer-loader
.
module: {
rules: [
{
test: /\.wasm$/,
type: 'javascript/auto',
loaders: ['arraybuffer-loader'],
},
],
},
MIT © Pine Mizune