arraybuffer-loader
v1.0.8
Published
Webpack loader that returns file contents as a ArrayBuffer
Downloads
41,286
Readme
ArrayBuffer loader for webpack
Supported Platforms
- Modern Browsers (IE >= 10)
- Node.js
Getting Started
$ yarn add arraybuffer-loader
or
$ npm install arraybuffer-loader --save-dev
Usage
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.
For .wasm
file
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'],
},
],
},
License
MIT © Pine Mizune