|
1 |
| -# **Electron-React-TypeScript-Base** |
| 1 | +# Electron-React-TypeScript-Webpack-Boilerplate |
| 2 | +Pre-configured Electron.js + React.js + TypeScript boilerplate with |
| 3 | +Webpack v4 & linters config predefined. |
2 | 4 |
|
3 |
| -This is a pre-configured Electron.js + React.js + TypeScript project with |
4 |
| -webpack v4 & TSLint config provided. `react-router` & `react-redux` is listed |
5 |
| -in dependencies section of `package.json`, and the folder structure is redux |
6 |
| -ready. |
| 5 | +This boilerplate currently works on macOS and Windows. If something doesn't |
| 6 | +work, please [file and issue](https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/issues/new). |
7 | 7 |
|
8 |
| -## **How Does It Work?** |
9 |
| -``` |
| 8 | +## Getting started |
| 9 | +```bash |
10 | 10 | // execute
|
11 | 11 | git clone https://github.com/iamWing/electron-react-typescript-base-proj.git
|
| 12 | +``` |
12 | 13 |
|
| 14 | +```json |
13 | 15 | // edit the following fields in package.json for your own project
|
14 | 16 | {
|
15 |
| - "name": {your-project-name}, |
16 |
| - "version": {what-ever-you-like}, |
17 |
| - "description": {your-own-description}, |
18 |
| - "author": {who's-the-author?}, |
19 |
| - "license": {if-you-don't-want-to-use-MIT} |
20 |
| - "repository": {type-and-link-of-your-repo}, |
21 |
| - "keywords": {keywords-of-your-project}, |
22 |
| - "bugs": {issue-page-of-your-repo}, |
23 |
| - "homepage": {homepage-of-your-repo} |
| 17 | + "name": {your-project-name}, |
| 18 | + "version": {whatever-you-like}, |
| 19 | + "description": {your-own-description}, |
| 20 | + "build": { |
| 21 | + "appId": {your-app-id}, |
| 22 | + "productName": {your-product-name}, |
| 23 | + "buildVersion": {whatever-you-like} |
| 24 | + }, |
| 25 | + "author": {who's-the-author?}, |
| 26 | + "license": {if-you-don't-want-to-use-MIT}, |
| 27 | + "repository": {type-and-link-of-your-repo}, |
| 28 | + "keywords": {keywords-of-your-project}, |
| 29 | + "bugs": {issue-page-of-your-repo}, |
| 30 | + "homepage": {homepage-of-your-repo} |
24 | 31 | }
|
25 | 32 | ```
|
26 | 33 |
|
27 |
| -## **Folder structure:** |
| 34 | +Then install all the `node_modules` needed by executing the following command: |
| 35 | +```bash |
| 36 | +cd {folder-containing-the-cloned-boilerplate} |
| 37 | +npm run install |
| 38 | +``` |
| 39 | + |
| 40 | +Finally execute the following command to start Webpack in development mode and |
| 41 | +watch the changes on source files. |
| 42 | +```bash |
| 43 | +npm run dev |
| 44 | +``` |
| 45 | + |
| 46 | +## Building the installer for your Electron app |
| 47 | +The boilerplate is currently configured to package & build the installer of |
| 48 | +your app for macOS & Windows using `electron-builder`. |
| 49 | + |
| 50 | +For macOS, execute: |
| 51 | +```bash |
| 52 | +npm run build:mac |
| 53 | +``` |
| 54 | + |
| 55 | +For Windows, execute: |
| 56 | +```bash |
| 57 | +npm run build:win |
| 58 | +``` |
| 59 | +_** `asar` archiving is disabled by default in Windows build as it can cause |
| 60 | +errors while running the installed Electron app based on pervious experiences, |
| 61 | +whereas the macOS build with `asar` enabled works just fine. You can turn it |
| 62 | +back on by removing line 23 (`"asar": false`) in `package.json`. **_ |
| 63 | + |
| 64 | +### Extra options |
| 65 | +The build scripts are pre-configured to build 64 bit installers since 64 bit |
| 66 | +should be the standard for a modern applications. 32 bit builds are still |
| 67 | +possible by changing the build scripts in `package.json` as below: |
| 68 | +```json |
| 69 | +// from |
| 70 | +"scripts": { |
| 71 | + ... |
| 72 | + "build:win": "electron-builder build --win --x64", |
| 73 | + "build:mac": "electron-builder build --mac --x64" |
| 74 | +}, |
| 75 | + |
| 76 | +// to |
| 77 | +"scripts": { |
| 78 | + ... |
| 79 | + "build:win": "electron-builder build --win --ia32", |
| 80 | + "build:mac": "electron-builder build --mac --ia32" |
| 81 | +}, |
| 82 | +``` |
| 83 | + |
| 84 | +Builds for Linux, armv71, and arm64 can also be configured by modifying the |
| 85 | +build scripts in `package.json`, but those aren't tested yet. For details, |
| 86 | +please refer to [documents of `electron-builder`](https://www.electron.build/cli). |
| 87 | + |
| 88 | +## Folder structure |
28 | 89 | ```
|
29 | 90 | electron-react-typescript-base-proj/
|
30 |
| -| - dist/ //- Generated by webpack automatically |
31 |
| -| | - index.html |
32 |
| -| | - main.bundle.js |
33 |
| -| | - renderer.bundle.js |
| 91 | +| - dist/ //- Generated by Webpack automatically |
34 | 92 | | - node_modules/
|
| 93 | +| - out/ //- Generated by build script automatically |
35 | 94 | | - public/ //- Global static assets
|
36 | 95 | | | - index.html
|
37 | 96 | | | - style.css
|
38 | 97 | | - src/
|
39 |
| -| | - actions/ //- Redux actions |
40 |
| -| | - main/ //- Electron / backend modules |
| 98 | +| | - main/ //- Backend modules for the Electron app |
41 | 99 | | | | - main.ts //- Entry point of 'electron-main'
|
42 | 100 | | | - models/
|
43 |
| -| | - reducers/ //- Redux reducers |
44 |
| -| | - renderer/ //- React / frontend components |
45 |
| -| | | - components/ |
46 |
| -| | | - containers/ |
| 101 | +| | - renderer/ //- Frontend React components for the Electron app |
47 | 102 | | | | - renderer.tsx //- Entry point of 'electron-renderer'
|
48 | 103 | | | - utils/ //- Common utilities
|
49 |
| -| | - declarations.d.ts |
50 | 104 | | - test/ //- Unit tests
|
| 105 | +| - .eslintrc //- ESLint config |
51 | 106 | | - .gitignore
|
52 | 107 | | - package-lock.json
|
53 | 108 | | - package.json
|
54 | 109 | | - tsconfig.json //- TypeScript config
|
55 | 110 | | - tslint.json //- TSLint config
|
56 |
| -| - webpack.common.js //- webpack base config |
57 |
| -| - webpack.dev.js //- webpack development config |
58 |
| -| - webpack.prod.js //- webpack production config |
| 111 | +| - webpack.config.js //- Webpack config |
59 | 112 | ```
|
60 | 113 |
|
61 |
| -## **License** |
62 |
| - |
63 |
| -MIT |
| 114 | +## License |
| 115 | +Electron React TypeScript Webpack Boilerplate is open source software |
| 116 | +[licensed as MIT](LICENSE). |
0 commit comments