简体   繁体   中英

Electron opening multiple windows package.json tweak

Here's my script in package.json file. It's opening multiple electron windows for some reason. How do i fix this ?

"startRender": "cross-env BROWSER=none npm run react-start",
"startElectron": "concurrently \"tsc ./electron/electron.ts -w\"  \"nodemon --exec 'wait-on http://localhost:3000 && electron electron/electron.js'\"",
"start": "concurrently \"npm run startElectron\"   \"npm run startRender\""

My project folder structure is like this :

.
├── electron
│   ├── electron.js
│   ├── electron.ts
│   ├── ipcEvents.js
│   ├── ipcEvents.ts
│   ├── messageSender.ts
│   ├── socketEvents.js
│   ├── socketEvents.ts
│   ├── Utils.ts
│   ├── windowEvents.js
│   └── windowEvents.ts
├── node_modules
├── package.json
├── package-lock.json
├── public
│   ├── favicon.ico
│   ├── index.html
│   └── manifest.json
├── src
│   ├── App.tsx
│   ├── index.css
│   ├── index.tsx
│   ├── react-app-env.d.ts
│   └── serviceWorker.ts
├── tsconfig.json

This is how my script looks for the electron with typescript and react . Its better to have the compiled .ts file to a separate folder. I am naming it build .

"scripts": {
    "react-start": "react-scripts start",
    "compile-electron": "tsc --module commonjs --noEmit false",
    "start": "concurrently \"cross-env BROWSER=none npm run react-start\" \"wait-on http://localhost:3000  && npm run compile-electron && electron ./build/electron.js\""
},

And here is the tsconfig.json looks like:

"compilerOptions": {
    "module": "esnext",
    "esModuleInterop": true,
    "target": "es6",
    "pretty": true,
    "strict": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "build",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve"
  },
  "include": [
    "electron/**/*.ts"
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM