1.2.0 • Published 6 years ago

electron-node-loader v1.2.0

Weekly downloads
70
License
MIT
Repository
github
Last release
6 years ago

electron-node-loader

yarn

This Webpack modules allows you to load a native Node.js C++ addon that can be shipped inside an Electron application.

Usage:

Let's picture an application folder:

project/
├── dist/
├── src/
│   └── main.js
└── scripts/
    └── addon.node

From your JavaScript code, you should be importing your custom module that way:

import * as addon from '../scripts/addon.node';

...

addon.doStuff();

When building your Electron app during development, add this rule to your Webpack config file:

loaders: [
  {
    test: /\.node?$/,
    use: [
      {
      	loader: 'electron-node-loader',
      	options: {
      	  folder: 'scripts'
      	}
      }
    ]
  }
]

If you're using electorn-builder for production, just add prod: true to the options object of the loader. You also need to add these lines in your package.json:

"files": [
  "!scripts",
],
"extraResources": [
  "scripts/*.node",
]

That way, your native addons with be shipped in a special resources directory inside of your app and your production JavaScript will be looking for them at runtime with a relative path.

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago