Module for loading native files in Node and Electron applications. The project is inspired by the node-addon-loader. It works in the similar way but allows to build path in the runtime.
Add the package to the package.json
file:
$ yarn add --dev native-ext-loader
Update webpack.config.js
file's rules:
module: {
rules: [
test: /\.node$/,
loader: 'native-ext-loader'
]
}
It is possible to adjust options:
module: {
rules: [
test: /\.node$/,
loader: 'native-ext-loader',
options: {
name: '[hex].[ext]',
rewritePath: path.resolve(__dirname, 'dist')
}
]
}
This option allows to change the file name in the output directory. You can use all placeholders defined in the loader-utils package.
This options allows to set an absolute path. Note that it needs to remain undefined
if you are building a package with embedded files.