Skip to content

Commit

Permalink
Optimize webpack bundler processor and refactor it
Browse files Browse the repository at this point in the history
  • Loading branch information
zourdyzou committed Jun 29, 2022
1 parent 1caeb7c commit 9e3a760
Show file tree
Hide file tree
Showing 73 changed files with 5,272 additions and 1,176 deletions.
5,048 changes: 4,341 additions & 707 deletions package-lock.json

Large diffs are not rendered by default.

105 changes: 70 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,65 +39,100 @@
"homepage": "https://github.com/zourdyzou/minesweeper#readme",
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.5",
"@babel/eslint-parser": "^7.18.2",
"@babel/preset-env": "^7.18.2",
"@babel/preset-react": "^7.17.12",
"@babel/preset-typescript": "^7.17.12",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.2.0",
"@types/jest": "^28.1.3",
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"babel-loader": "^8.2.5",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"core-js": "^3.23.3",
"cspell": "^6.1.2",
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^4.0.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.5.3",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.5.1",
"fork-ts-checker-webpack-plugin": "^7.2.11",
"html-minimizer-webpack-plugin": "^4.0.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^28.1.1",
"jest-environment-jsdom": "^28.1.0",
"lint-staged": "^12.4.2",
"mini-css-extract-plugin": "^2.6.1",
"mini-svg-data-uri": "^1.4.4",
"npm-check-updates": "^13.0.3",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
"postcss-preset-env": "^7.7.2",
"prettier": "^2.7.1",
"react-refresh": "^0.13.0",
"sass": "^1.53.0",
"sass-loader": "^13.0.1",
"style-loader": "^3.3.1",
"typescript": "^4.7.4",
"url-loader": "^4.1.1",
"webpack": "^5.73.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.2",
"webpack-merge": "^5.8.0"
"@babel/core": "~7.16.7",
"@babel/plugin-proposal-class-properties": "~7.16.7",
"@babel/plugin-proposal-export-default-from": "^7.16.7",
"@babel/plugin-proposal-export-namespace-from": "~7.16.7",
"@babel/plugin-proposal-object-rest-spread": "~7.16.7",
"@babel/plugin-proposal-throw-expressions": "~7.16.7",
"@babel/plugin-syntax-dynamic-import": "~7.8.3",
"@babel/plugin-transform-runtime": "~7.16.7",
"@babel/preset-env": "~7.16.7",
"@babel/preset-react": "~7.16.7",
"@babel/register": "~7.16.7",
"@pmmmwh/react-refresh-webpack-plugin": "~0.5.4",
"@svgr/webpack": "~6.1.2",
"@teamsupercell/typings-for-css-modules-loader": "~2.5.1",
"@typescript-eslint/eslint-plugin": "~5.9.0",
"@typescript-eslint/parser": "~5.9.0",
"autoprefixer": "~10.4.2",
"babel-eslint": "~10.1.0",
"babel-loader": "~8.2.3",
"clean-webpack-plugin": "~4.0.0",
"copy-webpack-plugin": "~10.2.0",
"core-js": "~3.20.2",
"cross-env": "^7.0.3",
"css-loader": "~6.5.1",
"cssnano": "~5.0.15",
"eslint": "~8.6.0",
"eslint-config-airbnb-base": "~15.0.0",
"eslint-config-airbnb-typescript": "~16.1.0",
"eslint-config-prettier": "~8.3.0",
"eslint-import-resolver-alias": "~1.1.2",
"eslint-plugin-import": "~2.25.4",
"eslint-plugin-jsx-a11y": "~6.5.1",
"eslint-plugin-react": "~7.28.0",
"eslint-plugin-react-hooks": "~4.3.0",
"eslint-webpack-plugin": "~3.1.1",
"fork-ts-checker-webpack-plugin": "~6.5.0",
"html-loader": "~3.1.0",
"html-webpack-plugin": "~5.5.0",
"import-sort-style-module-and-prefix": "~0.1.3",
"less": "~4.1.2",
"less-loader": "~10.2.0",
"mini-css-extract-plugin": "~2.4.6",
"path": "~0.12.7",
"postcss": "~8.4.5",
"postcss-loader": "~6.2.1",
"prettier": "~2.5.1",
"prettier-plugin-import-sort": "~0.0.7",
"pretty-quick": "~3.1.3",
"react-refresh": "~0.11.0",
"regenerator-runtime": "~0.13.9",
"resolve-url-loader": "~4.0.0",
"sass": "~1.47.0",
"sass-loader": "~12.4.0",
"sass-resources-loader": "~2.2.4",
"simple-git-hooks": "^2.7.0",
"style-loader": "~3.3.1",
"svg-url-loader": "~7.1.1",
"terser-webpack-plugin": "~5.3.0",
"ts-loader": "~9.2.6",
"typescript": "~4.5.4",
"url-loader": "~4.1.1",
"webpack": "~5.65.0",
"webpack-bundle-analyzer": "~4.5.0",
"webpack-cli": "~4.9.1",
"webpack-dev-server": "~4.7.2",
"webpack-merge": "~5.8.0",
"@types/classnames": "^2.3.0"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"classnames": "^2.3.1",
"normalize.css": "^8.0.1"
}
}
21 changes: 13 additions & 8 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React</title>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.5, minimum-scale=0.9, user-scalable=yes"
/>
<title>Webpack5 typescript react boilerplate</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap"
rel="stylesheet"
/>
</head>

<body>
<div id="root"></div>
<div id="root">Some base container message</div>
</body>

</html>
24 changes: 24 additions & 0 deletions src/@types/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
declare module "*.scss" {
const content: { [className: string]: string };
export = content;
}

declare module "*.less" {
const content: { [className: string]: string };
export = content;
}

declare module "*.svg" {
import React = require("react");
const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
export default ReactComponent;
}

declare module '*.json' {
const content: Record<string, string>;
export default content;
}

declare const IS_PROD: boolean;
declare const IS_DEV: boolean;
declare const IS_DEV_SERVER: boolean;
4 changes: 0 additions & 4 deletions src/@types/env.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/@types/react.d.ts

This file was deleted.

70 changes: 0 additions & 70 deletions src/@types/staticAssets.d.ts

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion src/assets/logo.svg

This file was deleted.

59 changes: 24 additions & 35 deletions src/components/App/App.module.scss
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
.appContainer {
text-align: center;
}

.appLogo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.appLogo {
animation: App-logo-spin infinite 20s linear;
}
}

.appHeader {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.styles {
&-header {
font-size: 50px;
color: #fff;
font-family: 'Open Sans', sans-serif;
font-weight: 600;
}

.appLink {
color: #61dafb;
}
&-image {
$size: 90px;
width: $size;
height: $size;
margin: 25px 0 0 0;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
&-link {
display: block;
margin: 20px 0 0 0;
font-family: 'Open Sans', sans-serif;
font-weight: 400;
color: #fff;
text-decoration: none;
&:hover {
color: #e8e8e8;
}
}
}
45 changes: 21 additions & 24 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import type { FunctionComponent, ReactElement } from "react";
import logo from '../../assets/logo.svg';
import styles from "./App.module.scss";
import type { PropsWithChildrenOnly } from "types/react";
import cn from 'classnames';
import React, {Suspense, lazy} from 'react';

import packageJson from '../../../package.json';
import {stylesContainer} from './app.module.less';
import {stylesHeader, stylesImage, stylesLink} from './app.module.scss';

export function App(): ReactElement {
return (
<div className={styles.appContainer}>
<Header logo={logo}>
<p>
Edit <code>src/App.tsx</code> and save to reload the browser
</p>
</Header>
const LazyStrawberryIcon = lazy(() => import('./strawberry'));
export const App = (): React.ReactElement => (
<div className={stylesContainer}>
<div className={stylesHeader}>It works</div>
<Suspense fallback={'loading...'}>
<LazyStrawberryIcon className={stylesImage} />
</Suspense>
<div>
<a
className={cn(stylesLink)}
href="https://github.com/glook/webpack-typescript-react"
target="_blank"
>
@glook/webpack-typescript-react ({packageJson.version})
</a>
</div>
</div>
);
}

type HeaderProps = {
logo?: string;
};

const Header: FunctionComponent<PropsWithChildrenOnly & HeaderProps> = ({ children, logo }) => (
<header className={styles.appHeader}>
{logo ? <img src={logo} className={styles.appLogo} alt="logo" /> : "There is no any logo!"}
{children}
</header>
);
Loading

0 comments on commit 9e3a760

Please sign in to comment.