electron-userland / electron-prebuilt-compile

electron-prebuilt with Babel and React built-in
168 stars 56 forks source link

How to use electron-prebuilt-compile in tandem with create-react-app? #79

Open AlmondBro opened 5 years ago

AlmondBro commented 5 years ago

Hi everyone,

How do we use electron-prebuilt-compile in tandem with create-react-app? I assume we do not build our project (nor use the build folder with react-scripts) since electron-prebuilt-compile will handle any ES6, React, LESS, etc. transpilation.

A couple notes about my current project: I have electron-prebuilt-compile in my dependencies.

My app works but in development but in production (compiling using electron-builder --dir) results in this error: image

This leads me to believe that electron-builder is not using electron-prebuilt-compile when compiling the app, hence the error on the importkeyword. Issues #73 & #74 are related to this.

I feel as i am missing maybe some extra configuration to remove this error.

The following is my package.json:

{
  "name": "CVUHSD-Waypoint",
  "description": "CVUHSD WayPoint is a desktop application where teachers can quickly access functions such as submitting a helpdesk ticket, calling the helpdesk, accessing the troubleshootign tutorials, or viewing announcements.",
  "version": "0.4.4-alpha",
  "private": false,
  "main": "src/electron-starter.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/JuanDavidLopez95/CVUHSD-WayPoint.git",
    "private": false
  },
  "dependencies": {
    "cors-anywhere": "^0.4.1",
    "dotenv": "^6.2.0",
    "electron-is-dev": "^1.0.1",
    "electron-prebuilt-compile": "^4.0.0",
    "electron-updater": "^4.0.6",
    "fullname": "^3.3.0",
    "macaddress": "^0.2.9",
    "node-notifier": "^5.4.0",
    "node-run-cmd": "^1.0.1",
    "prop-types": "^15.7.2",
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-pure-lifecycle": "^3.0.0",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.2.2",
    "react-scripts": "^2.1.8",
    "sendmail": "^1.4.1",
    "typescript": "^3.3.3333",
    "undefsafe": "^2.0.2",
    "windows-shortcuts": "^0.1.6"
  },
  "scripts": {
    "start": "set BROWSER=nul && react-scripts start",
    "server": "node src/server.js",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "electron": "electron .",
    "dev": "concurrently \"npm run start\" \"wait-on http://localhost:3000/ && electron .\"",
    "pack": "electron-builder --dir",
    "dist": "electron-builder",
    "build-pack": "npm run build && npm run pack",
    "build-dist": "npm run build && npm run dist",
    "electron-pack": "build --em.main=build/electron.js",
    "preelectron-pack": "npm build",
    "publish": "build --win -p always",
    "release": "build",
    "upload": "npm run build && npm run release"
  },
  "devDependencies": {
    "concurrently": "^4.1.0",
    "devtron": "^1.4.0",
    "electron": "^4.0.0",
    "electron-builder": "^20.38.5",
    "electron-react-devtools": "^0.5.3",
    "eslint-plugin-react": "^7.12.4",
    "wait-on": "^3.2.0",
    "why-did-you-update": "^1.0.6"
  },
  "keywords": [],
  "author": "CVUHSD",
  "homepage": "./",
  "build": {
    "publish": {
      "provider": "github",
      "repo": "CVUHSD-WayPoint",
      "owner": "JuanDavidLopez95",
      "private": true,
      "releaseType": "draft",
      "publishAutoUpdate": true
    },
    "asar": true,
    "extends": null,
    "productName": "WayPoint",
    "appId": "WayPoint",
    "compression": "store",
    "copyright": "Copyright © year `${author}`",
    "extraFiles": "./build/addFFCert",
    "files": [
      "build/**/*",
      "src/*",
      "src/electron-starter.js"
    ],
    "directories": {
      "buildResources": "./build"
    },
    "win": {
      "target": [
        {
          "target": "nsis",
          "arch": [
            "x64",
            "ia32"
          ]
        }
      ],
      "icon": "./public/img/wp-icon-grey-256x256.ico",
      "publisherName": "Centinela Valley Union High School District"
    },
    "nsis": {
      "oneClick": false,
      "perMachine": true,
      "allowToChangeInstallationDirectory": true,
      "installerIcon": "./public/img/wp-icon-grey.ico",
      "runAfterFinish": true,
      "menuCategory": true,
      "createDesktopShortcut": true
    }
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}