Skip to content

Latest commit

 

History

History
181 lines (152 loc) · 5.21 KB

11-03-2018-modular-architecture.md

File metadata and controls

181 lines (152 loc) · 5.21 KB

# Modular architecture - draft

  • Client : react app
  • server: express backend + db
  • electron: react app + custom backend compatible with electron

Electron - dev and production

  "scripts": {
    ...
    "start": "cross-env NODE_ENV=development electron .",
    ...

uses cross-env to set NODE_ENV to development or production electron, in package.json

in development listens to local host ./packages/electron/electron-starter.js

 if(process.env.NODE_ENV === 'development'){
          // and load the index.html of the app.
        mainWindow.loadURL('http://localhost:3000');
         // Open the DevTools.
        mainWindow.webContents.openDevTools();
    }
    else{

In production

else{
win.loadURL(`file://${path.join(__dirname, './build/index.html')}`)
...

## electron assets folder by default electron looks for assets like icons for the app, in a folder name built, to avoid confusiong we want to rename that folder to assets instead. we do so by adding "buildResources": "assets" under the electron build info in electron/package.json.

 "build": {
   ...
    "directories":{
      "buildResources": "assets"
    },

React router

The issue was with BrowserRouter of react-router. I had to change it to HashRouter and now all files and routes load properly.

from stackoverflow.com/questions/52093573/using-create-react-app-with-electron-builder

react


Used these guides:


build setup for electron builder, from autoEdit, to ignore ffmpeg static etc..

 "build": {
    "publish": {
      "provider": "github",
      "releaseType": "prerelease",
      "vPrefixedTagName": false
    },
    "appId": "org.autoEdit2.autoEdit2-electron",
    "asar": false,
    "files": [
      "**/*",
      "!config/",
      "!spec/",
      "!project_page/",
      "!vendor/",
      "!docs/",
      "!dist/",
      "!assets/",
      "node_modules/ffmpeg-static-electron/bin/${os}/${arch}/ffmpeg",
      "node_modules/ffmpeg-static-electron/index.js",
      "node_modules/ffmpeg-static-electron/package.json",
      "node_modules/ffprobe-static-electron/bin/${os}/${arch}/ffmpeg",
      "node_modules/ffprobe-static-electron/index.js",
      "node_modules/ffprobe-static-electron/package.json"
    ],
    "copyright": "2019 BBC - Pietro Passarelli",
    "mac": {
      "category": "public.app-category.productivity",
      "files": [
        "!node_modules/ffmpeg-static-electron/bin/win${/*}",
        "!node_modules/ffmpeg-static-electron/bin/linux${/*}",
        "!node_modules/ffprobe-static-electron/bin/win${/*}",
        "!node_modules/ffprobe-static-electron/bin/linux${/*}"
      ],
      "target": [
        {
          "target": "zip",
          "arch": [
            "x64"
          ]
        }
      ]
    },
    "linux": {
      "category": "",
      "packageCategory": "GNOME;GTK;VideoEditing;PaperEditing;Transcriptions",
      "description": "Desktop Client for Linux",
      "target": [
        "AppImage"
      ],
      "maintainer": "Pietro Passarelli <[email protected]>",
      "files": [
        "!node_modules/ffmpeg-static-electron/bin/linux/ia32${/*}",
        "!node_modules/ffmpeg-static-electron/bin/win${/*}",
        "!node_modules/ffmpeg-static-electron/bin/mac${/*}",
        "!node_modules/ffprobe-static-electron/bin/linux/ia32${/*}",
        "!node_modules/ffprobe-static-electron/bin/win${/*}",
        "!node_modules/ffprobe-static-electron/bin/mac${/*}"
      ]
    },
    "deb": {
      "synopsis": "Digital Paper-editing Desktop App"
    },
    "dmg": {
      "background": "build/background.png",
      "icon": "build/icon.icns",
      "iconSize": 128,
      "contents": [
        {
          "x": 448,
          "y": 340,
          "type": "link",
          "path": "/Applications"
        },
        {
          "x": 192,
          "y": 340,
          "type": "file"
        }
      ]
    },
    "win": {
      "target": "portable",
      "icon": "build/icon.ico",
      "files": [
        "node_modules/ffmpeg-static-electron/bin/win/${arch}/ffmpeg",
        "!node_modules/ffmpeg-static-electron/bin/win/ia32${/*}",
        "!node_modules/ffmpeg-static-electron/bin/linux${/*}",
        "!node_modules/ffmpeg-static-electron/bin/mac${/*}",
        "node_modules/ffprobe-static-electron/bin/win/${arch}/ffprobe",
        "!node_modules/ffprobe-static-electron/bin/win/ia32${/*}",
        "!node_modules/ffprobe-static-electron/bin/linux${/*}",
        "!node_modules/ffprobe-static-electron/bin/mac${/*}"
      ]
    }
  }