Electron-PWA-Wrapper
                                
                                 Electron-PWA-Wrapper copied to clipboard
                                
                                    Electron-PWA-Wrapper copied to clipboard
                            
                            
                            
                        Electron Wrapper to create Desktop Apps from offline-capable Progressive Web Apps
Electron PWA Wrapper
A sample wrapper app to package your Progressive Web App into a Desktop Application using Electron, Electon-Builder and Photon.
Drafted for the Desktop-version of my Leasing Calculator Web App using React, Redux, Materialize.css and a lot of Offline-First love over at leasingrechnen.at.
Looking for iOS or Android?
Check out my other projects:
- Android-PWA-Wrapper for Android
- iOS-PWA-Wrapper for iOS
Features
- build with electron-builder for macOS, Windows and Linux
- custom shell for each OS
- macOS TouchBar support
- handle connectivity issues natively in the wrapper
Wanna give it a try?
- clone repository, cd into the directory
- run npm installto get the dependencies
- run npm run electronto start the app
- check out /app/constants.js for more options (e.g. setting your own URL)
Basic Customizing
- Place your Tray- and App-Icons into src/assets.
- Change app/app_menu_template.jsto use your own Menu Items.
- Check app/constants.jsfor localizing your Strings (this project is German by default).- if you know how to do multi-language in Electron, a Pull-Request would be much appreciated!!
 
- While in app/constants.js, check thesettingsandmainWindowsections too.
- The Offline- and Loading-Screens are located in src/offline.htmlandsrc/loader.html, their corresponding images and styles insrc/res.
Custom Shell
You can create a custom shell for your WebApp for each OS, to give it a more native look and feel or add functionality you can't supply from your WebApp, using Photon.
- Go to srcdirectory and findshellMacOS.html,shellWindows.htmlorshellLinux.htmlto see a sample implementation of the shell.- You'll need to customize the whole template to your needs! This is plain HTML, so your configured values in the constants.js won't work.
- There's an example of a multi-column macOS shell with built-in navigation in src/shellMacOS-withMenu.html.
- If you create new events, sent by the shell to the Main process, you'll have to listen for and handle them in /index.js.
 
- In constants.json -> settings:- Locate usePhotonKitShell(macOS),useWindowsShelloruseLinuxShelland enable accordingly.
- Set nodeIntegrationEnabledto true.
- Set frameto false for macOS. For other OS', it depends on how you create your shell. I wouldn't recommend disabling the frame on Windows, as this hides your native Menu completely.
 
- Locate 
Building with electron-builder
Electron-PWA-Wrapper comes with electron-builder preconfigured for macOS (dmg, mas), Linux (AppImage) and Windows (Appx + Portable).
Preperations
- You'll need to
- look up your package.jsonand put your App's values in the build section
- and put all the required graphics into the builddirectory.
- See below, and the electron-builder Docs for further details!
 
- look up your 
- run npm run buildor./node_modules/.bin/electron-builder buildto start the build. Your app files will be located in thedistfolder.
Build for macOS App Store
- Have a machine running latest macOS ready, and latest XCode installed.
- Get a paid Apple Developer membership (~€99,- per year) and create Certificates, Identifiers and Provisioning Profiles for macOS:
- Certificates: Production -> Mac App Distribution and Mac Installer Distribution.
- Identifiers: App IDs -> create one with your package/bundle name (e.g. 'com.example.myawesomeapp').
- Provisioning Profiles: Distribution -> Mac Distribution for the Identifier you just created.
 
- Download the certificates and double-click them to get them installed in your local Keychain.
- Download and copy your Provisioning Profile to the project root and rename it to embedded.provisionprofile.
- Make sure you've updated your package.json->build-> appId, productName, copyright and mac->category
- Put the required icons in place:
- in build->icon.iconset, replace all the icons in the folder. Sizes and namings are important!
- open the terminal, navigate to buildand run the following command to create youricon.icnsfrom the iconset you've just populated.- iconutil -c icns icon.iconset
 
 
- in 
- Edit the build/Info.plistandbuild/entitlements.mas.plistand replace YourTeamId and YourPackageId.- You can find your Team ID on the Apple Developer Account in Membership.
- Your package ID is the bundle identifier you've created in the step above (e.g. 'com.example.myawesomeapp').
 
- Run npm run buildfrom the terminal.- If it fails, you might have to give the process proper permission by running sudo ./node_modules/.bin/electron-builder buildinstead.
 
- If it fails, you might have to give the process proper permission by running 
Build for Windows Store
- Have a machine running Windows 10 Enterprise ready, with all latest updates and windows-build-toolsinstalled.
- Get a paid Windows Dev Center Publisher Account (~€25,- once) and sign up for DesktopBridge Support for your app.
- Create your App in the Windows Dev Dasboard to get the values for the next step.
- Update your package.json->build->win-> legalTrademarks and publisherName, and all the attributes inbuild->appx.
- Put the required icons in place:
- in build: icon.ico
- in build/appx: replace all the icons in the folder. Sizes and namings are important!
 
- in 
- Run npm run buildfrom the command line (preferably from PowerShell).
Build for Linux (any distro, using AppImage)
- Have a machine running up-to-date Ubuntu or Debian ready. Install Node.JS >= 6 as described here (or as you prefer).
- Install build dependencies: sudo apt install -y icnsutils graphicsmagick
- Create your build/icon.icnslike described in Build for macOS App Store. Also, don't forget to place your Tray- and App-Icons intosrc/assets.
- Update your package.json->build->linuxand ->appImage.
- Run npm run buildand find your .AppImage in thedistfolder.
- Tell your users to run chmod a+x *.AppImageor to change permissions via GUI to make the file executable.
License
GNU General Public License v3.0 - if you use it, we wanna see it! Other licensing options are available on inquiry.