bennymeg / nx-electron

Electron schematics for nrwl nx platform
Apache License 2.0
328 stars 85 forks source link
cross-platform electron monorepo ngx nx schematics

# Nx Electron Electron builders and schematics for Nrwl Nx platform. [![License](https://img.shields.io/github/license/bennymeg/nx-electron.svg?color=40bb12)](https://github.com/bennymeg/nx-electron/blob/master/LICENSE) [![NPM Version](https://img.shields.io/npm/v/nx-electron.svg)](https://www.npmjs.com/package/nx-electron) [![Downloads](https://img.shields.io/badge/downloads-500k+-respect)](https://npm-stat.com/charts.html?package=nx-electron&from=2019-11-01) [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/bennymeg) [![Star this repo](https://img.shields.io/github/stars/bennymeg/nx-electron?style=social)](https://github.com/bennymeg/nx-electron)



Features

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

Compitability

This repository follows the semantic versioning rules while adhering to Nx and Angular versioning scheme. Make sure that nx-electron major version matching Nx major version. I.e. version 19.x of nx-electron will be compatible with version 19.y of Nx.

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@19

Make sure to select Integrated monorepo as a project style, and Webpack as a bundler. 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 Nx 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 Nx Electron Application

Serving Nx Electron Application

Packaging Nx Electron Application

The options that can be passed are described here.

Making Nx Electron Application

The options that can be passed are described here.

Configuring static packaging / making options

It is possible to configure all the packaging / making options in .\apps\<electron-app-name>\src\app\options\maker.options.json. For more information read this article. 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 Nx Electron Application

To migrate automatically run ng update nx-electron@<version>. You can find detailed information in the following migration guides.

Testing Nx Electron Application

Debugging Nx 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

Attribution

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



Author: Benny Megidish.