Skip to content

Commit 400da3f

Browse files
marceloaugusto80Marcelo Augusto
andauthored
Cleanup and documentation (#24)
* update dependencies * react function comps and ts webpack * refactor structure * fix hot reload and cleanup * improve font bundling * typescript paths * clean up * clean up * fix router not working in file protocol * fix fs error in main-process * fix require not defined in render process * fix dialogs using electron remote * fix dialog with electron remote * cleanup * add package.json to bundle * cleanup * update documentation * cleanup and documentation Co-authored-by: Marcelo Augusto <[email protected]>
1 parent 74c065d commit 400da3f

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

readme.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
![](./.github/project-logo-400.jpg)
33

44

5-
#### Template project for desktop apps using:
5+
#### Slim template for desktop apps using:
66
- [Electron](https://electronjs.org/)
77
- [Typescript](https://www.typescriptlang.org/)
88
- [React](https://reactjs.org/)
@@ -14,20 +14,30 @@
1414
<br>
1515

1616
# Before anything
17-
As always, install packages:
17+
As always, install packages.
18+
Open a terminal in the project root folder and run:
1819
```cmd
1920
$ npm install
2021
```
2122

2223

2324
# During development
2425

26+
### Start the app in **development** mode (**with** hot reload).
2527
Run:
2628
```cmd
2729
$ npm start
2830
```
2931
It will launch webpack dev server and electron [concurrently](https://www.npmjs.com/package/concurrently).
3032
It has [fast refresh](https://www.npmjs.com/package/react-refresh-webpack-plugin) (AKA hot-reload) enabled by default.
33+
<br/>
34+
<br/>
35+
<br/>
36+
### Start app in **production** mode (**without** hot reload).
37+
Run:
38+
```cmd
39+
$ npm run start:prod
40+
```
3141

3242
# Testing
3343
Run:
@@ -41,5 +51,5 @@ Just run:
4151
```cmd
4252
$ npm run pack
4353
```
44-
and the output will be in the ```./pack``` folder.
54+
and the output will available in the ```./pack``` folder.
4555

src/main/main-process.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ app.whenReady()
3838
initialize();
3939

4040
win.maximize();
41-
enable(win?.webContents);
42-
41+
enable(win.webContents);
4342

4443
win.on("closed", () => {
4544
win = null;
4645
});
4746

48-
4947
app.on('window-all-closed', () => {
5048
if (process.platform != "darwin") {
5149
app.quit()

src/renderer/styles/GlobalStyle.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const GlobalStyle = createGlobalStyle`
99
margin: 0 !important;
1010
padding: 0 !important;
1111
font-family: Roboto;
12-
font-weight: 600;
1312
}
1413
1514
a {

src/renderer/views/ExampleView1.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ export function ExampleView1() {
1818
return (
1919
<div>
2020
<h1>Example view 1</h1>
21+
<h3>Just a example view</h3>
22+
<p>An image:</p>
2123
<img src={clock} />
22-
<p>{theNumber}</p>
24+
<p>A counter:</p>
25+
<p><strong>{theNumber}</strong></p>
2326
</div>
2427
);
2528

src/renderer/views/ExampleView2.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export function ExampleView2() {
2626
return (
2727
<div>
2828
<h1>Example view 2</h1>
29-
<p>Try to open a file</p>
29+
<h3>Another example view.</h3>
30+
<p>Try to open a file to test electron dialog and file system:</p>
3031
<button onClick={handleOpenFileClick}>Open file...</button>
3132
{
3233
text &&

src/shared/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
put scripts used by both renderer and main process here.
1+
put scripts and modules used by both renderer and main process here.
22
import then like: import {something} from "@/shared/something";

webpack.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ function RendererConfiguration(env: Env): Configuration {
120120
electronRenderer: true
121121
},
122122

123-
mode: env.development ? "development" : "production",
124-
125-
devtool: env.development ? "source-map" : undefined,
126-
127123
entry: {
128124
"renderer-process": "./renderer-process.tsx"
129125
},

0 commit comments

Comments
 (0)