Code Monkey home page Code Monkey logo

electroangular's Introduction

How to create a desktop app for Windows and OSX in less than 10 minutes with Electron

This repository's goal is to present to you Electron and how we used this awesome technology to develop a desktop app for one of our clients.

More details about our adventure are present on the blog article we published, available here.

Table of contents

  1. Write your first Electron app
  2. Package your app to serve it to any platform
  3. Unleash the power of AngularJS
  4. File association in Windows

How does this boilerplate works ?

We created this boilerplate using :

We then configured custom npm tasks to help you get up and running as fast as possible. Here is the "scripts" section of our package.json file:

package.json

"scripts" : {
  "start": "electron ./app",
  "clean": "rm -rf ./dist",
  "pack": "npm run pack:linux32 && npm run pack:linux64 && npm run pack:osx && npm run pack:win32 && npm run pack:win64",
  "pack:linux32": "electron-packager ./app $npm_package_name --out=dist/ --platform=linux --arch=ia32 --version=0.34.1 --overwrite",
  "pack:linux64": "electron-packager ./app $npm_package_name --out=dist/ --platform=linux --arch=x64 --version=0.34.1 --overwrite",
  "pack:osx": "electron-packager ./app $npm_package_name --out=dist/ --platform=darwin --arch=x64 --version=0.34.1 --icon=assets/osx/icon.icns --overwrite",
  "pack:win32": "electron-packager ./app $npm_package_name --out=dist/ --platform=win32 --arch=ia32 --version=0.34.1 --icon=assets/win/icon.ico --overwrite",
  "pack:win64": "electron-packager ./app $npm_package_name --out=dist/ --platform=win32 --arch=x64 --version=0.34.1 --icon=assets/win/icon.ico --overwrite",
  "build": "npm run clean && build:osx && build:win32 && build:win64",
  "build:osx": "npm run pack:osx && electron-builder dist/$npm_package_name-darwin-x64 --platform=osx --out=dist/$npm_package_name-darwin-x64 --config=build-config.json",
  "build:win32": "npm run pack:win32 && electron-builder dist/$npm_package_name-win32-ia32 --platform=win --out=dist/$npm_package_name-win32-ia32  --config=build-config.json",
  "build:win64": "npm run pack:win64 && electron-builder dist/$npm_package_name-win32-x64 --platform=win --out=dist/$npm_package_name-win32-x64 --config=build-config.json"
}

Launch the app

To start the app locally, you simply have to run

$ npm start

This will go to the app folder and launch the Electron main process defined in the app/main.js script.

To package your app for the different platforms, you have at your disposal the following commands :

  • $ npm run pack:linux32 : Packs the application for 32-bits Linux distributions
  • $ npm run pack:linux64 : Packs the application for 64-bits Linux distributions
  • $ npm run pack:osx: Packs the application for 64-bits Mac OSX
  • $ npm run pack:win32 : Packs the application for 32-bits Windows
  • $ npm run pack:win64 : Packs the application for 64-bits Windows
  • $ npm run pack : Packs your app for all of the above operating systems

If you want to build installers for your app, you can use the following commands:

  • $ npm run build:osx : Creates a .dmg file to install your app on Mac OSX computers, using the images you defined in the corresponding section of the build-config.json file.
  • $ npm run build:win32 : Creates a .exe file to install your app on Windows computers, using the images you defined in the corresponding section of the build-config.json file.
  • $ npm run build:win64 :Creates a .exe file to install your app on Windows computers, using the images you defined in the corresponding section of the build-config.json file.
  • $ npm run build: Builds your app for all of the above platforms
dist
├── your-app-name-darwin-x64
│   └── my-awesome-app.app
│   └── my-awesome-app.dmg
└── your-app-name-win32-ia32
    └── my-awesome-app Setup.exe

Here is the result under Windows!

Alt text

Team

electroangular's People

Contributors

shpleef avatar

Watchers

James Cloos avatar  avatar

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.