Skip to content

Commit 738d4f1

Browse files
Merge branch 'develop' of https://github.com/ita-social-projects/StreetCode_Client into refactor-art-gallery
2 parents e996972 + b0b2d87 commit 738d4f1

File tree

33 files changed

+8503
-1679
lines changed

33 files changed

+8503
-1679
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ npm-debug.log*
3232
yarn-debug.log*
3333
yarn-error.log*
3434
package-lock.json
35+
36+
#certificate
37+
/cert

README.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,38 @@ Back-end part: https://github.com/ita-social-projects/StreetCode.git.
1616

1717
## Table of Contents
1818

19-
- [Installation](#installation)
20-
- [Required to install](#required-to-install)
21-
- [Clone](#clone)
22-
- [Setup](#setup)
23-
- [How to run local](#how-to-run-local)
24-
- [Usage](#usage)
25-
- [How to run tests](#how-to-run-tests)
26-
- [Documentation](#documentation)
27-
- [Contributing](#contributing)
28-
- [GitHub flow](#github-flow)
29-
- [Issue flow](#github-flow)
30-
- [Team](#team)
31-
- [FAQ](#faq)
32-
- [Support](#support)
33-
- [About Us](#about-us)
34-
- [License](#license)
19+
- [Streetcode](#streetcode)
20+
- [Table of Contents](#table-of-contents)
21+
- [Installation](#installation)
22+
- [Required to install](#required-to-install)
23+
- [Clone](#clone)
24+
- [Setup](#setup)
25+
- [Prerequisites](#prerequisites)
26+
- [Installation Steps](#installation-steps)
27+
- [How to run local](#how-to-run-local)
28+
- [Usage](#usage)
29+
- [How to run tests](#how-to-run-tests)
30+
- [Documentation](#documentation)
31+
- [Contributing](#contributing)
32+
- [Gitflow](#gitflow)
33+
- [Step 1](#step-1)
34+
- [Step 2](#step-2)
35+
- [Step 3](#step-3)
36+
- [Step 4](#step-4)
37+
- [Step 5](#step-5)
38+
- [Step 6](#step-6)
39+
- [Step 7](#step-7)
40+
- [Step 8](#step-8)
41+
- [Step 9](#step-9)
42+
- [Hotfixes](#hotfixes)
43+
- [Step 1](#step-1-1)
44+
- [Step 2](#step-2-1)
45+
- [Issue flow](#issue-flow)
46+
- [Team](#team)
47+
- [FAQ](#faq)
48+
- [Support](#support)
49+
- [About Us](#about-us)
50+
- [License](#license)
3551

3652
---
3753

@@ -58,6 +74,29 @@ To setup this project use this command in project folder:
5874
npm install
5975
```
6076

77+
To facilitate the usage of Workbox in our project, we have a few setup steps. Follow these instructions carefully:
78+
79+
#### Prerequisites
80+
81+
Before proceeding, ensure you have [Chocolatey](https://chocolatey.org/install) installed on your system.
82+
83+
#### Installation Steps
84+
85+
1. Install `mkcert` by running the following command from PowerShell (administrative):
86+
```
87+
choco install mkcert
88+
```
89+
2. Create a `cert` folder in the root directory of cloned project.
90+
3. Navigate to the `cert` folder in your console.
91+
4. Run the following commands to generate SSL certificates:
92+
```
93+
mkcert -install
94+
```
95+
```
96+
mkcert localhost 127.0.0.1
97+
```
98+
5. In `webpack.dev.js` file update DevServer section according to comment left there.
99+
61100
### How to run local
62101
To start project locally, write following command:
63102
```

config/webpack.dev.js

Lines changed: 105 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,112 @@
1-
const Dotenv = require('dotenv-webpack');
2-
const Webpack = require('webpack');
1+
const Dotenv = require("dotenv-webpack");
2+
const Webpack = require("webpack");
3+
const { GenerateSW } = require("workbox-webpack-plugin");
4+
const fs = require("fs");
35

46
module.exports = {
5-
entry: {
6-
main: './src/index.tsx',
7-
},
8-
devtool: 'cheap-module-source-map',
9-
devServer: {
10-
open: true,
11-
port: "3000",
12-
historyApiFallback: true,
13-
},
14-
module: {
15-
rules: require('./webpack.rules'),
16-
},
17-
resolve: {
18-
extensions: ['.tsx', '.ts', '.js'],
19-
symlinks: false,
20-
alias: require('./webpack.aliases'),
21-
},
22-
output: {
23-
filename: '[name].bundle.js',
24-
chunkFilename: '[name].chunk.js',
25-
publicPath: '/'
7+
entry: {
8+
main: "./src/index.tsx",
9+
},
10+
devtool: "cheap-module-source-map",
11+
devServer: {
12+
open: true,
13+
port: "3000",
14+
historyApiFallback: true,
15+
https: {
16+
// DEV.NOTE: uncomment and change names of files according to your generated ones
17+
18+
// key: fs.readFileSync("cert\\localhost+1-key.pem"),
19+
// cert: fs.readFileSync("cert\\localhost+1.pem"),
2620
},
27-
plugins: [
28-
...require('./webpack.plugins'),
29-
new Dotenv({
30-
path: `./.env`,
31-
}),
32-
],
33-
optimization: {
34-
splitChunks: {
35-
chunks: 'all',
36-
minSize: 0,
37-
cacheGroups: {
38-
vendor: {
39-
test: /[\\/]node_modules[\\/]/,
40-
name(module) {
41-
// get the name of the package
42-
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
21+
},
22+
module: {
23+
rules: require("./webpack.rules"),
24+
},
25+
resolve: {
26+
extensions: [".tsx", ".ts", ".js"],
27+
symlinks: false,
28+
alias: require("./webpack.aliases"),
29+
},
30+
output: {
31+
filename: "[name].bundle.js",
32+
chunkFilename: "[name].chunk.js",
33+
publicPath: "/",
34+
},
35+
plugins: [
36+
...require("./webpack.plugins"),
37+
new Dotenv({
38+
path: `./.env`,
39+
}),
40+
new GenerateSW({
41+
skipWaiting: true,
42+
clientsClaim: true,
43+
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
44+
runtimeCaching: [
45+
{
46+
urlPattern: /\.(?:js|css)$/,
47+
handler: 'CacheFirst',
48+
options: {
49+
cacheName: 'static-resources',
50+
expiration: {
51+
maxAgeSeconds: 60 * 60 * 24 * 7, // 1 week
52+
},
4353

44-
// exlude @ symbol from package name (cause it may be used by the server)
45-
return `npm.${packageName.replace('@', '')}`;
46-
}
47-
},
54+
},
55+
},
56+
{
57+
urlPattern: /\.(?:png|jpg|jpeg|svg|gif)$/,
58+
handler: 'CacheFirst',
59+
options: {
60+
cacheName: 'image-resources',
61+
expiration: {
62+
maxAgeSeconds: 60 * 60 * 24 * 7, // 1 week
4863
},
64+
},
4965
},
66+
{
67+
urlPattern: /\.(?:woff|woff2|ttf|otf)$/,
68+
handler:'CacheFirst',
69+
options: {
70+
cacheName: 'font-resources',
71+
expiration: {
72+
maxAgeSeconds: 60 * 60 * 24 * 90, // 3 months
73+
},
74+
},
75+
},
76+
{
77+
urlPattern: /^https?.*/,
78+
handler: 'StaleWhileRevalidate',
79+
options: {
80+
cacheName: 'external-resources',
81+
expiration: {
82+
maxEntries: 260
83+
},
84+
},
85+
},
86+
],
87+
}),
88+
],
89+
optimization: {
90+
splitChunks: {
91+
chunks: "all",
92+
minSize: 0,
93+
cacheGroups: {
94+
vendor: {
95+
test: /[\\/]node_modules[\\/]/,
96+
name(module) {
97+
// get the name of the package
98+
const packageName = module.context.match(
99+
/[\\/]node_modules[\\/](.*?)([\\/]|$)/
100+
)[1];
101+
102+
// exlude @ symbol from package name (cause it may be used by the server)
103+
return `npm.${packageName.replace("@", "")}`;
104+
},
105+
},
106+
},
50107
},
51-
performance: {
52-
hints: false,
53-
},
54-
}
108+
},
109+
performance: {
110+
hints: false,
111+
},
112+
};

config/webpack.prod.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const Dotenv = require('dotenv-webpack');
22
const CopyPlugin = require('copy-webpack-plugin');
33
const path = require('path');
44
const webpack = require("webpack");
5+
const { GenerateSW } = require("workbox-webpack-plugin");
56

67
module.exports = {
78
entry: {
@@ -46,6 +47,54 @@ module.exports = {
4647
},
4748
],
4849
}),
50+
new GenerateSW({
51+
skipWaiting: true,
52+
clientsClaim: true,
53+
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
54+
runtimeCaching: [
55+
{
56+
urlPattern: /\.(?:js|css)$/,
57+
handler: 'CacheFirst',
58+
options: {
59+
cacheName: 'static-resources',
60+
expiration: {
61+
maxAgeSeconds: 60 * 60 * 24 * 7, // 1 week
62+
},
63+
64+
},
65+
},
66+
{
67+
urlPattern: /\.(?:png|jpg|jpeg|svg|gif)$/,
68+
handler: 'CacheFirst',
69+
options: {
70+
cacheName: 'image-resources',
71+
expiration: {
72+
maxAgeSeconds: 60 * 60 * 24 * 7, // 1 week
73+
},
74+
},
75+
},
76+
{
77+
urlPattern: /\.(?:woff|woff2|ttf|otf)$/,
78+
handler:'CacheFirst',
79+
options: {
80+
cacheName: 'font-resources',
81+
expiration: {
82+
maxAgeSeconds: 60 * 60 * 24 * 90, // 3 months
83+
},
84+
},
85+
},
86+
{
87+
urlPattern: /^https?.*/,
88+
handler: 'StaleWhileRevalidate',
89+
options: {
90+
cacheName: 'external-resources',
91+
expiration: {
92+
maxEntries: 260
93+
},
94+
},
95+
},
96+
],
97+
}),
4998
],
5099
optimization: {
51100
splitChunks: {

jest.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ const jestConfig: JestConfigWithTsJest = {
3939
},
4040
coverageThreshold: {
4141
global: {
42-
statements: 8.6,
43-
branches: 5.6,
44-
functions: 6.4,
45-
lines: 8.7,
42+
statements: 8.5,
43+
branches: 5.4,
44+
functions: 6.3,
45+
lines: 8.6,
4646
},
4747
},
4848
};

0 commit comments

Comments
 (0)