One Framework To Rule Them All
Complete setup for developing multi platform solutions with Angular, NativeScript and Electron.JS
- Business logic is platform independant
- Using familiar technology
- Having the native experience
Generating The Shared Angular & NativeScript project
This project was generated with Angular CLI version 6.1.0 with NativeScript schematics included. Shared flag transforms the project to shared Angular & NativeScript project.
ng new --collection=@nativescript/schematics --style=scss --shared <appname>
More about Angular Schematics can be found on the Angular Docs page.
More on using the NativeScript Angular Schematics.
Adding the Electron.JS Dev Dependency
npm install electron --save-dev
Also, the electron-packager is added as a Dev Dependency as we are going to use it as a Application Distribution tool.
npm install electron-packager --save-dev
And in order to deploy our Electron App, we are going to use this command:
electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch> [optional flags...]
Adding a service worker to the project
To set up the Angular service worker in your project, use the CLI command ng add @angular/pwa. It takes care of configuring your app to use service workers by adding the service-worker package along with setting up the necessary support files.
ng add @angular/pwa
Also, for testing our PWA app, we'll need some HTTP Server.
npm install lite-server --save-dev
After that, we'll need to build our app.
ng build --prod
And then we can start our local HTTP server.