This starter kit should save you the setup work to wire up Webpack, TypeScript and Electron. By the end, you'll have:
We assume that you're already using Node.js with npm.
We'll create a new project called my-app:
git clone https://github.com/gorillabyte/electron-typescript-starter-kit my-app
cd my-app
npm installYou can also use yarn:
git clone https://github.com/gorillabyte/electron-typescript-starter-kit my-app
cd my-app
yarnAt this point, your project layout should look like the following:
my-app/
├─ .gitignore
├─ .npmrc
├─ .prettierrc
├─ node_modules/
├─ src/
│ └─ ...
├─ templates/
│ └─ ...
├─ package.json
├─ tsconfig.json
├─ tslint.json
└─ webpack.config.js
Of note:
tsconfig.jsoncontains TypeScript-specific options for the project.package.jsoncontains our dependencies, as well as some shortcuts for commands we'd like to run during development and deploying our app.srccontains our TypeScript and CSS code.main.tsis the entry-point for the Electron app andrenderer.tsis the application running in the Electron window, they are mandatory.templatescontains our SCSS code and the HTML template for the app. Theindex.htmlwill be copied during the build step to the build folder.webpack.config.jscontains the Webpack configuration.
Running the project is as simple as running
npm run devThis runs the dev script specified in our package.json, and will spawn off a server which reloads and serves the page in the Electron app as we save our files.
Normally the server runs at http://localhost:9000.
This tightens the iteration loop by allowing us to quickly preview changes during development.
To run your project within the electron environment simply run
npm run startThis project is licensed under the MIT license, Copyright (c) 2020 Gorillabyte. For more information see LICENSE.