numpy-loader
A webpack loader for binary numpy .npy files
Usage
Configure the loader in your webpack.config.js
under module
> rules
, e.g. like this:
test: /\.$/ exclude: /node_modules/ loader: 'numpy-loader' options: outputPath: 'assets/data'
You can specify an outputPath
that will be used during compilation.
You can now load .npy
files as ndarray
s in your JS code simply by require
ing them. There are two modes, for small and large npy files respectively:
Small files
Load small .npy
files directly from the webpack bundle using embed=true
. These files will be base64 encoded and become a part of your webpack bundle.
let npyarray = ;console;console;
Large files
You might not want to embed particularly large files in your webpack bundle. You can specify embed=false
(or nothing; it's the default) to copy your .npy
files to your output directory and load them as binary files from your server at runtime instead. Thus you need to use the #load()
callback like this:
const npyarray = npyarray