W3cubDocs

/webpack

node-loader

Node Add-ons for webpack

Install

npm install --save-dev node-loader

Usage

Executes node add-ons in enhanced-require.

Use the loader either via your webpack config, CLI or inline.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.node$/,
        use: 'node-loader'
      }
    ]
  }
}

In your application

import node from 'file.node';

CLI

webpack --module-bind 'node=node-loader'

In your application

import node from 'file.node';

Inline

In your application

import node from 'node-loader!./file.node';

© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/loaders/node-loader