Yet another native node addon loader. The project is an enhanced version inspired by node-addon-loader and node-native-loader.
In electron-based applications generally use asar to pack resources and if there are node addon which depends on other native modules like dlls on Windows or so on Linux/Mac, the .node module should be unpacked, but any existed loader could not work with this condition. Relative loader is born to solve this issue.
Add the package to the development dependencies:
# using npm:
$ npm install relative-loader --save-dev
# using yarn:
$ yarn add --dev relative-loader
Update rules entry in the Webpack configuration file:
module: {
rules: [
{
test: /\.node$/,
loader: "relative-loader"
}
];
}
Options are configurable using options
hash:
unlike node-native-loader options is required!
module: {
rules: [
{
test: /\.node$/,
loader: "relative-loader",
options: {
relativePath: "/../../"
}
}
];
}
It allows to set an relative paths to node addon files.
Attention Please make sure the relativePath
starts and ends with slash
or backslash
(MAKE SURE Windows \\\\
not \\
)