You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-19Lines changed: 45 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,39 +46,46 @@ The `./dist/` folder is the root of the site. It is created by Webpack and conta
46
46
npm run dev
47
47
```
48
48
49
+
### Server-Side Rendering
50
+
49
51
`./src` contains `App.tsx`, which is the entry point of the React app. It imports components from `./src/shared` and global styles from `./assets/styles/`. `App.tsx` is in turn imported by server (`server.tsx`) and client (`index.tsx`) files in `./src/server/` and `./src/client/`, respectively.
50
52
51
53
The `app.get()` method in server code (`./src/server/server.tsx`) specifies a callback function that will render to string React component from `App.tsx` and past it in a HTML template (`./src/server/indexTemplate.ts`), whenever there is an HTTP GET request with a path (`/`) relative to the site root.
52
54
53
-
After the `load` event is fired, the client code `hydrate` obtained React root.
55
+
After the `load` event is fired, the client code `hydrate` obtained React root. The `hydrate` method is used to render React components on the client side. It is similar to `render`, but it will attach event listeners to the existing markup instead of replacing it.
56
+
57
+
### Hot Module Replacement
58
+
59
+
Hot Module Replacement is one of the most useful features offered by webpack. It allows all kinds of modules or files to be updated at runtime without the need for a full refresh. This includes CSS and JS files, as well as static assets that are part of the dependency graph. When a file is changed, the module is replaced, and the application code is re-executed. During such module replacement a component's state is preserved.
60
+
61
+
### Typescript checking
62
+
63
+
After each re-building webpack plugin `fork-ts-checker-webpack-plugin` checks the typescript code for errors.
64
+
65
+
### Static files
54
66
55
67
All files in `./src/static/` are copied to the `./dist/client` folder without changes. For example, the `./src/static/images` folder will be copied to `./dist/client/images`. All files in `./src/static` are accessible through the virtual prefix `/static`. For example, the `./src/static/images/raster/favicon/favicon.png` file will be available at the address `http://localhost:3000/static/images/raster/favicon/favicon.png` === `/static/images/raster/favicon/favicon.png`.
56
68
69
+
### Image optimization
70
+
57
71
Images in `./src/static/images` are optimized by Webpack. For images with `jpeg` or `jpg` or `png` extentions, the `image-minimizer-webpack-plugin` and `sharp` generate a WebP version of the images.
58
72
59
-
After each re-building webpack plugin `fork-ts-checker-webpack-plugin` checks the typescript code for errors.
73
+
### Browserslist
60
74
61
75
The `browserslist` is used by babel and postcss to compile code for the specified browsers. The list of browsers is specified in the `package.json` file.
62
76
63
-
## What is used in the template?
64
-
65
-
### Code
77
+
### Testing
66
78
67
-
- Webpack loader (babel-loader)
68
-
- Webpack plugin (fork-ts-checker-webpack-plugin)
69
-
- browserslist
79
+
It is possible to write snapshot tests (using `jest` and `react-test-renderer`) and tests for React components (using the `react-testing-library` library).
70
80
71
-
### Styles
81
+
The template contains a simple tests for the `Header` component. The test is located in the `./src/__tests__/Header.test.tsx` file.
0 commit comments