Reputation: 13247
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
Upvotes: 0
Views: 343
Reputation: 980
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"
]
}
Upvotes: 1