1

I'm making a video game with create-react-app and typescript. I've tried distributing with electron but it is such a mess and I'm totally lost. I've put so much effort on this game that I really need to make a proper .exe build for, and now that I want to make a build I'm totally lost and helpless.

Also, there are some stuff I need to be able to do:

  • I need to be able to change resolution from the .tsx files
  • I need to be able to toggle fullscreen from the .tsx files
  • I need to be able to load assets located in /src
  • Everything needs to run locally and even offline
  • I need my public folder to be trully accessible and moddable for the end user

I can't find anything that I can properly understand and execute after several weeks of trying.

Please help.

nb: I did this eject thing once to fix electron which can't be undone.

directories and how things are structured

My package.json file:

{
  "name": "<the name>",
  "author": "<my name>",
  "version": "0.1.0",
  "description": "<the description>",
  "private": true,
  "dependencies": {
    "@babel/core": "7.9.0",
    "@electron/typescript-definitions": "^8.7.4",
    "@kennethormandy/react-fittext": "^0.6.0",
    "@material-ui/icons": "^4.9.1",
    "@react-native-community/async-storage": "^1.10.0",
    "@svgr/webpack": "4.3.3",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "@typegoose/typegoose": "^7.0.0",
    "@types/jest": "^24.9.1",
    "@types/mongoose": "^5.7.14",
    "@types/node": "^12.12.37",
    "@types/react": "^16.9.34",
    "@types/react-beautiful-dnd": "^12.1.2",
    "@types/react-dom": "^16.9.7",
    "@types/socket.io-client": "^1.4.32",
    "@types/tweenjs": "^1.0.0",
    "@typescript-eslint/eslint-plugin": "^2.10.0",
    "@typescript-eslint/parser": "^2.10.0",
    "alm": "^2.39.1",
    "babel-eslint": "10.1.0",
    "babel-jest": "^24.9.0",
    "babel-loader": "8.1.0",
    "babel-plugin-named-asset-import": "^0.3.6",
    "babel-preset-react-app": "^9.1.2",
    "camelcase": "^5.3.1",
    "case-sensitive-paths-webpack-plugin": "2.3.0",
    "css-loader": "3.4.2",
    "dotenv": "8.2.0",
    "dotenv-expand": "5.1.0",
    "electron-browser-storage": "^1.0.6",
    "electron-simple-window-manager": "^1.1.1",
    "electron-store": "^5.1.1",
    "eslint": "^6.6.0",
    "eslint-config-react-app": "^5.2.1",
    "eslint-loader": "3.0.3",
    "eslint-plugin-flowtype": "4.6.0",
    "eslint-plugin-import": "2.20.1",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.19.0",
    "eslint-plugin-react-hooks": "^1.6.1",
    "file-loader": "4.3.0",
    "fs-extra": "^8.1.0",
    "howler": "^2.2.0",
    "html-webpack-plugin": "4.0.0-beta.11",
    "identity-obj-proxy": "3.0.0",
    "jest": "24.9.0",
    "jest-environment-jsdom-fourteen": "1.0.1",
    "jest-resolve": "24.9.0",
    "jest-watch-typeahead": "0.4.2",
    "mini-css-extract-plugin": "0.9.0",
    "mongoose": "^5.9.11",
    "optimize-css-assets-webpack-plugin": "5.0.3",
    "pnp-webpack-plugin": "1.6.4",
    "popmotion": "^8.7.3",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-normalize": "8.0.1",
    "postcss-preset-env": "6.7.0",
    "postcss-safe-parser": "4.0.1",
    "react": "^16.13.1",
    "react-app-polyfill": "^1.0.6",
    "react-aspect-ratio": "^1.0.42",
    "react-beautiful-dnd": "^13.0.0",
    "react-dev-utils": "^10.2.1",
    "react-dnd": "^10.0.2",
    "react-dnd-html5-backend": "^10.0.2",
    "react-dom": "^16.13.1",
    "react-draggable": "^4.3.1",
    "react-fittext": "^1.0.0",
    "react-icons": "^3.10.0",
    "react-image-tint": "^1.0.2",
    "react-native-easy-dnd": "^1.0.2",
    "react-responsive-spritesheet": "^2.3.9",
    "react-textfit": "^1.1.0",
    "react-z-index": "^3.0.0",
    "resolve": "1.15.0",
    "resolve-url-loader": "3.1.1",
    "sass-loader": "8.0.2",
    "semver": "6.3.0",
    "socket.io-client": "^2.3.0",
    "style-loader": "0.23.1",
    "terser-webpack-plugin": "2.3.5",
    "ts-pnp": "1.1.6",
    "tweenjs": "^1.0.2",
    "typescript-react-draggable": "^1.0.0",
    "url-loader": "2.3.0",
    "webpack": "4.42.0",
    "webpack-dev-server": "3.10.3",
    "webpack-manifest-plugin": "2.2.0",
    "workbox-webpack-plugin": "4.3.1",
    "xml-js": "^1.6.11"
  },
  "scripts": {
    "pack": "electron-builder build --dir",
    "dist": "npm run build && electron-builder build",
    "postinstall": "install-app-deps",
    "start": "nf start -p 3000",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js",
    "eject": "node scripts/eject.js",
    "electron": "electron .",
    "electron-start": "node src/electron-wait-react.js",
    "react-start": "set BROWSER=nul && node scripts/start.js"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@types/express": "^4.17.6",
    "@types/howler": "^2.1.2",
    "@types/socket.io": "^2.1.4",
    "electron-builder": "^22.6.0",
    "express": "^4.17.1",
    "foreman": "^3.0.1",
    "node-sass": "^4.14.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-native-web": "0.11.2",
    "socketio": "^1.0.0",
    "typescript": "^3.8.3"
  },
  "homepage": "./",
  "jest": {
    "roots": [
      "<rootDir>/src"
    ],
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,ts,tsx}",
      "!src/**/*.d.ts"
    ],
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "setupFilesAfterEnv": [],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
      "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
    ],
    "testEnvironment": "jest-environment-jsdom-fourteen",
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "modulePaths": [
      "C:\\Users\\mr003\\Documents\\programmation\\ZwangReact\\zwang\\src"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "web.ts",
      "ts",
      "web.tsx",
      "tsx",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ],
    "watchPlugins": [
      "jest-watch-typeahead/filename",
      "jest-watch-typeahead/testname"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  }
}

selm
  • 19
  • 2
  • There are many tutorials and existing questions on Stack Overflow about this topic. You said that you've read a lot about this, but don't include any links. It would help if you could point to any Stack Overflow posts in particular that you've read so that we don't suggest you read something you've already read. – Heretic Monkey May 22 '20 at 13:17
  • 1
    Dear @selm, it might be much easier for people to help if you describe what tools you use (e.g. electron, rnw), what have you done so far (eg. steps you took so far), what went well and what didn't (e.g error messages and what is not working). Otherwise; the answers may be so broad and hard to compose and they might not be related to your goals. – Hilmi Erdem KEREN May 22 '20 at 13:27
  • Hi, thanks for your reply. Not sure I have the links, but I have tried electron and electron builder. Everything did well until I ran into this: https://stackoverflow.com/questions/45022112/electron-builder-not-allowed-to-load-local-resource-app-asar-build-index-html which I still can't fix Then I also couldn't access the public folder at all when using electron-builder I've also tried NW.js but when I launch my index.html file from the build folder it is just a black screen Also I've tried https://create-react-app.dev/docs/deployment/ (under "other solutions") doesn't work neither – selm May 22 '20 at 13:27
  • @HilmiErdemKEREN thanks for your reply. I have been using electron until the "how to build" question arrised. It worked well and I liked having the ipcRenderer accessible in the .tsx files. I tried electron builder and I couldn't archieve to make the public folder accessible to the end user, nor to run my app at all. I also tried NW.js but I can't figure it out despite the doc – selm May 22 '20 at 13:30
  • I'd suggest that you STOP – and work on a test project, solving each problem, one at a time. Also, you should look at your `dependencies` – it looks like there is a lot of stuff in there that are `devDependencies` – and they will only make your app even bigger that the rather plump Electron standard size. What you want to do is totally possible. – spring May 22 '20 at 13:50
  • @spring I think you are right. 1st I'm going to solve that black page issue I think I can already find ressources about this :) – selm May 22 '20 at 14:14

0 Answers0