9.0.0-beta.9 ā€¢ Published 4 years ago

nx-electron-test v9.0.0-beta.9

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

Nx Electron

Electron builders and schematics for Nrwl Nx platform.

licence npm version Dependencies status

Features

Nx Electron provides a set of power ups on Nx for developing cross platform desktop apps using Electron.

  • Schematics: Provides schematics for developing cross platform apps in a mono repo environment.
  • Typescript: Uses Typescript to help reduce errors, and create more structured code.
  • Obfuscation: Since Electron are used on the client machines, nx-electron obfuscates you code (and only it). šŸ†•
  • Minimization: Electron apps tend to be quite large, hence we use webpack to bundle, and minimize to code.
  • Live Update: Provides continuos live reload for your backend code.
  • Event Templates: Provides templates for common events like squirrel setup events, auto update events and IPC events. šŸ†•
  • Packaging: Packages your frontend and backend webpack bundles into single electron package. šŸ†•
  • Making: Makes your frontend and backend webpack bundles into single executable. šŸ†•

Getting Started

Prerequisite

This module is based on Nx, you will need to set up an Nx workspace before you can use nx-electron.

npx create-nx-workspace@latest

You should also create a frontend project in you workspace (in any nx supported framework you like) for you electron app.

Installation

npm install -D nx-electron

Creating Electron Application

nx g nx-electron:app <electron-app-name> --frontendProject=<frontend-app-name>

NOTE: You should add a frontend project to you workspace prior to invoking this command.

NOTE: On certain frontend platforms (such as Angular, React, etc...) it is important to change the baseHref field to "./", and use the hash strategy on the router in order for it to work well with electron. Further details can be found here.

Building Electron Application

  • Run nx build <electron-app-name> to build your application.

Serving Electron Application

  • Run nx serve <electron-app-name> to serve your application.

Packaging Electron Application

  • Run nx run <electron-app-name>:package [--options] to package your application.

The options that can be passed are described here. Notice: in order to use the packaging features you will have to either migrate your project manually or create a new project (v8.0.0 or newer).

Configuring static packaging options

It is possible to configure all the packaging that are describes above in .\apps\<electron-app-name>\src\app\options\packager.options.json. Notice: the option you define at this file will override the options you pass manually via the command line or choose via the angular console.

Making Electron Application

  • Run nx run <electron-app-name>:make [--options] to make your application.

The options that can be passed are described here. Notice: in order to use the making features you will have to either migrate your project manually or create a new project (v9.0.0 or newer).

Configuring static making options

It is possible to configure all the making that are describes above in .\apps\<electron-app-name>\src\app\options\maker.options.json. Notice: the option you define at this file will override the options you pass manually via the command line or choose via the angular console.

Migrating Electron Application

You can find detailed information in the following articles:

Testing Electron Application

  • Run nx test <electron-app-name> to test your application.

Debugging Electron Application

Minimal Project Structure

Regardless of what framework you chose, the resulting file tree will look like this:

<workspace name>/
ā”œā”€ā”€ apps/
ā”‚   ā”œā”€ā”€ electron-app-name/
ā”‚   ā”œā”€ā”€ frontend-app-name/
ā”‚   ā””ā”€ā”€ frontend-app-name-e2e/
ā”œā”€ā”€ libs/
ā”œā”€ā”€ tools/
ā”œā”€ā”€ nx.json
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
ā””ā”€ā”€ tslint.json

Support

If you're having any problem, please raise an issue on GitHub and we'll be happy to help.

Contribute

Before submitting a pull request, please make sure that you include tests and lints runs without any warnings.

Versioning

This repository follows the semantic versioning rules while adhering to Nx and Angular version scheme.

Attribution

This project is highly inspired by (and dependent on) Nrwl Nx platform. Under the hood, we use Electron Packager to package the electron application and Electron Builder to make executables.

Author: Benny Megidish.