Skip to content

Instantly share code, notes, and snippets.

@hrdtbs
Last active May 16, 2021 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrdtbs/a6d5554bbc6e0973dcf4c7d2e04b5b66 to your computer and use it in GitHub Desktop.
Save hrdtbs/a6d5554bbc6e0973dcf4c7d2e04b5b66 to your computer and use it in GitHub Desktop.
electron, typescript, react
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();
}
};
{
"scripts": {
"dev:renderer": "webpack-cli serve --mode development",
"dev:main": "electron-forge start",
"dev": "concurrently yarn:dev:*",
"typecheck": "tsc -p . --noEmit"
}
}
{
"compilerOptions": {
"target": "es2019",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react"
}
}
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