Last active
May 16, 2021 12:37
-
-
Save hrdtbs/a6d5554bbc6e0973dcf4c7d2e04b5b66 to your computer and use it in GitHub Desktop.
electron, typescript, react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createWindow = () => { | |
window = new BrowserWindow({ | |
title: app.name, | |
width: 1024, | |
height: 640, | |
transparent: true, | |
frame: false, | |
webPreferences: { | |
worldSafeExecuteJavaScript: false, | |
nodeIntegration: true, | |
contextIsolation: false, | |
preload: path.resolve(`${__dirname}/preload.js`), | |
}, | |
}); | |
if( app.isPackaged){ | |
window.loadFile(`dist/index.html`); | |
}else{ | |
window.loadURL("http://localhost:8080/") | |
window.openDevTools(); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"dev:renderer": "webpack-cli serve --mode development", | |
"dev:main": "electron-forge start", | |
"dev": "concurrently yarn:dev:*", | |
"typecheck": "tsc -p . --noEmit" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es2019", | |
"module": "esnext", | |
"moduleResolution": "node", | |
"strict": true, | |
"esModuleInterop": true, | |
"forceConsistentCasingInFileNames": true, | |
"jsx": "react-jsx", | |
"jsxImportSource": "@emotion/react" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const HTMLPlugin = require("html-webpack-plugin"); | |
module.exports = { | |
target: 'electron-renderer', | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
use: { | |
loader: "ts-loader", | |
options: { | |
transpileOnly: true, | |
}, | |
}, | |
}, | |
], | |
}, | |
resolve: { | |
extensions: [".js", ".ts", ".tsx", ".json"], | |
}, | |
plugins: [ | |
new HTMLPlugin({ | |
template: path.join(__dirname, "src/index.html"), | |
}) | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment