node-native-loader
A webpack loader for node native modules (.node/C++ binaries).
What it does
This loader moves all relevant files (generally, .node
files) to the output path, then uses
relative paths to load them, so that they can be loaded in a consistent location across different
builds of an app (development vs packaged, etc.).
It is similar to node-relative-loader, but
has a number of problematic options removed, and works consistently on Windows (whereas the
aforementioned module often generates non-working require statements).
Usage
const config = {
module: {
loaders: {
{
test: /\.node$/,
loader: 'node-native?from=app',
},
}
}
}
A note on webpack-dev-server
If you're using webpack-dev-server
(or webpack-dev-middleware
), you probably also want to add
write-file-webpack-plugin to your
configuration for all .node
files, so that they still get written to the filesystem and can be
required consistently.
License
MIT