Giter Club home page Giter Club logo

electron-node-loader-chimaera's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.