Skip to content

Commit a37017d

Browse files
author
Turbo Thinh
committed
feat: update packages
1 parent 9c8475a commit a37017d

File tree

11 files changed

+5646
-5712
lines changed

11 files changed

+5646
-5712
lines changed

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rules:
1717
- devDependencies: true
1818

1919
react/destructuring-assignment:
20-
- never
20+
- off
2121

2222
env:
2323
es6: true # enable all ECMAScript 6 features except for modules (this automatically sets the ecmaVersion parser option to 6).

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
A simple React boilerplate that allow you to understand easily, embrace good practices and workflow, optimizing for production and does not do any magic.
44

55
### Features
6-
1. SEO optimized
6+
- [x] Hot-loader
7+
- [x] Absolute import (like `Assets/images/img.png` instead of `../../assets/images/img.png`)
8+
- [x] Style with `SASS` / `SCSS`
9+
- [x] Bundle optimization:
10+
* `CSS` bundle with option to easily hash className with CSS module
11+
* Minify `CSS`, `JS`
12+
* Automaticaly create `Analyzer` file after build
13+
* Create `/compressed` folder for extra optimization (use optionally)
14+
* Add Image optimization
15+
* Split build to chunks for caching and fast loading
16+
* Lazy-loading enabled
17+
- [x] SEO optimized
718
* robots.txt
819
* Auto generate sitemap
920
* `meta` tags added allow easy configuration
1021
* Social media sharing optimized
11-
2. Easy development experience with hot-loader
12-
3. Add `Polyfill` automatically to browser (This is redundant since Babel 7)
13-
4. Automatically resolve stastic path (like `Assets/images/img.png` instead of `../../assets/images/img.png`)
14-
5. `SASS` / `SCSS` compiler (easy to customize predecesor of your own with `LESS`, `Stylus`... using the same format)
15-
6. `CSS` bundle with option to easily hash className with CSS module
16-
7. Minify `CSS`, `JS`
17-
8. Automaticaly create `Analyzer` file after build
18-
9. Create `/compressed` folder for extra optimization (use optionally)
19-
10. Add Image optimization
20-
11. Split build to chunks for caching and fast loading
21-
12. Lazy-loading enabled
22+
- [x] Netlify config for easy deployment
2223

2324
### Get started
2425
- To run the app: `yarn start`
25-
- To build the app: `yarn build`
26+
- To build the app: `yarn build`.
2627

2728
### License
2829
MIT license

package.json

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,52 @@
99
"lint": "eslint .",
1010
"lint fix": "eslint . --fix",
1111
"build": "webpack --mode production --config webpack/prod.config.js",
12-
"start": "webpack-dev-server --mode development --config webpack/dev.config.js --open --hot"
12+
"build:start": "npx serve dist",
13+
"start": "webpack serve --mode development --config webpack/dev.config.js --open --hot"
14+
},
15+
"dependencies": {
16+
"react": "^17.0.1",
17+
"react-dom": "^17.0.1"
1318
},
1419
"devDependencies": {
15-
"@babel/core": "^7.0.0",
16-
"@babel/plugin-proposal-class-properties": "^7.0.0",
17-
"@babel/preset-env": "^7.0.0",
18-
"@babel/preset-react": "^7.0.0",
19-
"babel-eslint": "^9.0.0",
20-
"babel-loader": "^8.0.2",
20+
"@babel/core": "^7.12.10",
21+
"@babel/plugin-proposal-class-properties": "^7.12.1",
22+
"@babel/preset-env": "^7.12.11",
23+
"@babel/preset-react": "^7.12.10",
24+
"babel-eslint": "^10.1.0",
25+
"babel-loader": "^8.2.2",
2126
"babel-plugin-import-inspector": "^2.0.0",
22-
"compression-webpack-plugin": "^1.1.12",
23-
"copy-webpack-plugin": "^4.5.2",
24-
"css-loader": "^0.28.11",
25-
"eslint": "^5.5.0",
26-
"eslint-config-airbnb": "^17.1.0",
27-
"eslint-import-resolver-webpack": "^0.10.1",
28-
"eslint-plugin-import": "^2.14.0",
29-
"eslint-plugin-jsx-a11y": "^6.1.1",
30-
"eslint-plugin-react": "^7.11.1",
31-
"file-loader": "^1.1.11",
32-
"html-webpack-plugin": "^3.2.0",
33-
"image-webpack-loader": "^4.3.1",
34-
"imagemin-mozjpeg": "^7.0.0",
35-
"imagemin-webpack-plugin": "^2.2.0",
36-
"mini-css-extract-plugin": "^0.4.0",
37-
"node-sass": "^4.13.1",
38-
"optimize-css-assets-webpack-plugin": "^4.0.1",
39-
"prop-types": "^15.6.2",
40-
"react-helmet": "^5.2.0",
41-
"react-lazyload": "^2.3.0",
42-
"react-router-dom": "^4.3.1",
43-
"sass-loader": "^7.0.1",
44-
"svg-url-loader": "^2.3.2",
45-
"uglifyjs-webpack-plugin": "^1.3.0",
46-
"url-loader": "^1.0.1",
47-
"webpack": "^4.8.3",
48-
"webpack-bundle-analyzer": "^2.13.1",
49-
"webpack-cli": "^2.1.3",
50-
"webpack-dev-server": "^3.1.4",
51-
"webpack-merge": "^4.1.4"
52-
},
53-
"dependencies": {
54-
"react": "^16.3.2",
55-
"react-dom": "^16.3.2"
27+
"clean-webpack-plugin": "^3.0.0",
28+
"compression-webpack-plugin": "^7.1.1",
29+
"copy-webpack-plugin": "^7.0.0",
30+
"css-loader": "^5.0.1",
31+
"eslint": "^7.16.0",
32+
"eslint-config-airbnb": "^18.2.1",
33+
"eslint-import-resolver-webpack": "^0.13.0",
34+
"eslint-plugin-import": "^2.22.1",
35+
"eslint-plugin-jsx-a11y": "^6.4.1",
36+
"eslint-plugin-react": "^7.22.0",
37+
"file-loader": "^6.2.0",
38+
"html-webpack-plugin": "^4.5.0",
39+
"image-webpack-loader": "^7.0.1",
40+
"imagemin-mozjpeg": "^9.0.0",
41+
"imagemin-webpack-plugin": "^2.4.2",
42+
"mini-css-extract-plugin": "^1.3.3",
43+
"node-sass": "^5.0.0",
44+
"optimize-css-assets-webpack-plugin": "^5.0.4",
45+
"prop-types": "^15.7.2",
46+
"react-helmet": "^6.1.0",
47+
"react-lazyload": "^3.1.0",
48+
"react-router-dom": "^5.2.0",
49+
"sass-loader": "^10.1.0",
50+
"svg-url-loader": "^7.1.1",
51+
"uglifyjs-webpack-plugin": "^2.2.0",
52+
"url-loader": "^4.1.1",
53+
"webpack": "^5.11.1",
54+
"webpack-bundle-analyzer": "^4.3.0",
55+
"webpack-cli": "^4.3.1",
56+
"webpack-dev-server": "^3.11.1",
57+
"webpack-merge": "^5.7.3"
5658
},
5759
"engines": {
5860
"node": ">=10.0.0"

src/components/Gallery/Gallery.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const Gallery = () => (
1313
<div>
1414
<div key="31341" className={classes([appStyles.box, appStyles.mt30])}>
1515
<span className={appStyles.mt30}>
16-
* Images are credited to Unplash and Pixabay
16+
* Images are credited to Unplash and Pixabay
1717
<br />
18-
This section is made to test copy + display images in different formats
18+
This section is made to test copy + display images in different formats
1919
</span>
2020

2121
<div className={classes([styles.masonryColumns, appStyles.mt30])}>
2222

23-
{ photos.map(obj => (
23+
{ photos.map((obj) => (
2424
<LazyLoad offset={100} height={100} key={generateKey()}>
2525
<div className={styles.masonryItem} key={generateKey()}>
2626
<img className={styles.masonryImg} key={generateKey()} alt={obj} src={obj} />

src/components/Header/Header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import icon from 'Assets/images/react-icon.png';
77
import { classes } from 'Includes/ultilities';
88
import styles from './Header.sass';
99

10-
const Header = props => (
10+
const Header = (props) => (
1111
<div className={styles.nav}>
1212
<div className={classes([layout.box, styles.navInner])}>
1313

src/components/Loading/Loading.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
const Loading = () => (
44
<div>
5-
Component is loading
5+
Component is loading
66
</div>
77
);
88

src/routes/routes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { HashRouter, Route, Switch } from 'react-router-dom';
44
import { Helmet } from 'react-helmet';
55
import favicon from 'Assets/images/favicon.png';
66

7-
87
import Home from 'Containers/Home/Home';
98
import Login from 'Containers/Login/Login';
109
import NotFound404 from 'Containers/404/404';

webpack/base.config.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
const path = require('path');
22

3+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
34
const HtmlWebpackPlugin = require('html-webpack-plugin');
45
const CopyWebpackPlugin = require('copy-webpack-plugin');
5-
66
const ImageminPlugin = require('imagemin-webpack-plugin').default;
77
const imageminMozjpeg = require('imagemin-mozjpeg');
88

99
module.exports = {
1010
entry: {
11-
main: [
12-
// '@babel/polyfill',
13-
'./src/index.js'],
11+
main: ['./src/index.js'],
1412
},
1513
resolve: {
1614
alias: {
@@ -51,8 +49,8 @@ module.exports = {
5149
use: {
5250
loader: 'url-loader',
5351
options: {
54-
// Images larger than 25 KB won’t be inlined
55-
limit: 100 * 1024,
52+
limit: 100 * 1024, // Images larger than 25 KB won’t be inlined
53+
esModule: false,
5654
},
5755
},
5856
},
@@ -72,19 +70,23 @@ module.exports = {
7270
],
7371
},
7472
plugins: [
73+
// Clean bundle
74+
new CleanWebpackPlugin(),
7575

7676
// Initiate html template
7777
new HtmlWebpackPlugin({
7878
template: './src/index.html',
7979
}),
8080

8181
// Copy all assets to dist folder
82-
new CopyWebpackPlugin([
83-
{ from: 'src/assets/images', to: 'assets/images' },
84-
{ from: 'src/assets/photos', to: 'assets/photos' },
85-
{ from: 'src/config/sitemap.xml', to: 'sitemap.xml' },
86-
{ from: 'src/config/robots.txt', to: 'robots.txt' },
87-
]),
82+
new CopyWebpackPlugin({
83+
patterns: [
84+
{ from: 'src/assets/images', to: 'assets/images' },
85+
{ from: 'src/assets/photos', to: 'assets/photos' },
86+
{ from: 'src/config/sitemap.xml', to: 'sitemap.xml' },
87+
{ from: 'src/config/robots.txt', to: 'robots.txt' },
88+
],
89+
}),
8890

8991
// Optimmize images
9092
new ImageminPlugin({

webpack/dev.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
const merge = require('webpack-merge');
1+
const { merge } = require('webpack-merge');
22
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
33
const baseConfig = require('./base.config.js');
44

5-
65
// TODO: Add Lazy Loading, Optimize code splitting, Split chunks
76

87
module.exports = merge(baseConfig, {
@@ -19,9 +18,10 @@ module.exports = merge(baseConfig, {
1918
{
2019
loader: 'css-loader',
2120
options: {
22-
// If enable CSS Modular, hence hashing classNames
23-
modules: true,
24-
localIdentName: '[local]',
21+
modules: {
22+
localIdentName: '[name]__[local]',
23+
},
24+
sourceMap: false,
2525
},
2626
},
2727
{

webpack/prod.config.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
const merge = require('webpack-merge');
1+
const { merge } = require('webpack-merge');
22
const path = require('path');
3-
43
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
54
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
65
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
76
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // eslint-disable-line
87
const CompressionPlugin = require('compression-webpack-plugin');
98
const baseConfig = require('./base.config.js');
109

11-
1210
module.exports = merge(baseConfig, {
1311

1412
// Define Build output
@@ -28,12 +26,10 @@ module.exports = merge(baseConfig, {
2826
{
2927
loader: 'css-loader',
3028
options: {
31-
// If disable CSS Modular
32-
// modules: false,
33-
34-
// If enable CSS Modular, hence hashing classNames
35-
modules: true,
36-
localIdentName: '[hash:base64:6]',
29+
modules: {
30+
localIdentName: '[name]__[local]___[hash:base64:5]',
31+
},
32+
sourceMap: true,
3733
},
3834
},
3935
{
@@ -62,9 +58,9 @@ module.exports = merge(baseConfig, {
6258

6359
// Compress
6460
new CompressionPlugin({
65-
asset: 'compressed/[path].gz[query]',
66-
algorithm: 'gzip',
6761
test: /\.js$|\.css$|\.html$/,
62+
deleteOriginalAssets: false,
63+
algorithm: 'gzip',
6864
threshold: 10240,
6965
minRatio: 0.8,
7066
}),

0 commit comments

Comments
 (0)