Skip to content

Commit 4dfd3e3

Browse files
committed
upgrade webpack
1 parent 61f61d8 commit 4dfd3e3

File tree

5 files changed

+1663
-3893
lines changed

5 files changed

+1663
-3893
lines changed

package.json

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,51 +57,47 @@
5757
"@types/chai": "^4.3.0",
5858
"@types/classnames": "^2.3.1",
5959
"@types/dom4": "^2.0.2",
60-
"@types/html-webpack-plugin": "2.30.2",
6160
"@types/lodash": "^4.14.180",
6261
"@types/mocha": "^5.2.7",
6362
"@types/prop-types": "^15.7.4",
6463
"@types/react": "^18.0.15",
65-
"@types/react-dnd-multi-backend": "^6.0.2",
6664
"@types/react-dom": "^18.0.6",
67-
"@types/react-hot-loader": "^3.0.6",
65+
"@types/react-hot-loader": "^4.1.1",
6866
"@types/uuid": "^3.4.10",
69-
"@types/webpack": "^3.8.21",
67+
"@types/webpack": "^5.28.0",
7068
"chai": "^4.3.6",
71-
"css-loader": "^0.28.11",
69+
"css-loader": "^6.7.3",
7270
"dnd-core": "16.0.1",
73-
"file-loader": "^1.1.11",
74-
"html-loader": "^0.5.5",
75-
"html-webpack-plugin": "^2.30.1",
71+
"file-loader": "^6.2.0",
72+
"html-loader": "^4.2.0",
73+
"html-webpack-plugin": "^5.5.0",
7674
"jsdom": "^15.2.1",
7775
"jsdom-global": "^3.0.2",
7876
"less": "^3.13.1",
79-
"less-loader": "^5.0.0",
77+
"less-loader": "^11.1.0",
8078
"less-plugin-autoprefix": "^2.0.0",
8179
"mocha": "^7.2.0",
8280
"mocha-junit-reporter": "^1.23.3",
8381
"npm-run-all": "^4.1.5",
8482
"prettier": "^2.6.1",
8583
"react": "^18.2.0",
8684
"react-dom": "^18.2.0",
87-
"react-hot-loader": "^3.1.3",
88-
"source-map-loader": "^0.2.4",
89-
"style-loader": "^0.20.3",
90-
"ts-loader": "^3.5.0",
85+
"react-hot-loader": "^4.13.1",
86+
"source-map-loader": "^4.0.1",
87+
"style-loader": "^3.3.1",
88+
"ts-loader": "^9.4.2",
9189
"ts-node": "^8.10.2",
9290
"tslint": "^6.1.3",
9391
"tslint-config-prettier": "^1.18.0",
9492
"tslint-plugin-prettier": "^2.3.0",
9593
"tslint-react": "^5.0.0",
9694
"typescript": "^4.6.3",
97-
"webpack": "^3.12.0",
98-
"webpack-dev-server": "^2.11.5",
95+
"webpack": "^5.75.0",
96+
"webpack-cli": "^5.0.1",
97+
"webpack-dev-server": "^4.11.1",
9998
"yarn-deduplicate": "^3.1.0"
10099
},
101100
"peerDependencies": {
102101
"react": "16 - 18"
103-
},
104-
"resolutions": {
105-
"dnd-core": "16.0.1"
106102
}
107103
}

webpack/base.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ const config: webpack.Configuration = {
1414
filename: '[name].js',
1515
path: CONSTANTS.DOCS_DIR,
1616
},
17-
devtool: '#source-map',
17+
devtool: 'source-map',
1818
resolve: {
1919
extensions: ['.webpack.js', '.web.js', '.json', '.ts', '.js', '.tsx'],
2020
},
21+
optimization: {
22+
moduleIds: 'named'
23+
},
2124
module: {
2225
rules: [
2326
{
@@ -74,14 +77,8 @@ const config: webpack.Configuration = {
7477
],
7578
},
7679
plugins: [
77-
new webpack.NamedModulesPlugin(),
78-
new webpack.optimize.CommonsChunkPlugin({
79-
name: 'vendor',
80-
minChunks: Infinity,
81-
}),
8280
new HtmlWebpackPlugin({
8381
template: CONSTANTS.HTML_TEMPLATE,
84-
chunksSortMode: 'dependency',
8582
}),
8683
],
8784
};

webpack/bundle.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import webpack from 'webpack';
22
import config from './base';
33

4-
const bundleConfig = {
4+
const bundleConfig: webpack.Configuration = {
55
...config,
6+
optimization: {
7+
...config.optimization,
8+
minimize: true,
9+
},
610
plugins: [
711
...(config.plugins || []),
812
new webpack.DefinePlugin({
@@ -12,9 +16,6 @@ const bundleConfig = {
1216
new webpack.LoaderOptionsPlugin({
1317
minimize: true,
1418
}),
15-
new webpack.optimize.UglifyJsPlugin({
16-
sourceMap: true,
17-
}),
1819
],
1920
};
2021

webpack/hot.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import webpack from 'webpack';
22
import config from './base';
33
import { CONSTANTS } from './constants';
4+
import 'webpack-dev-server';
45

5-
const baseEntry = config.entry as webpack.Entry;
6+
const baseEntry = config.entry as webpack.EntryObject;
67
const entry = {
78
...baseEntry,
89
app: [
@@ -20,7 +21,7 @@ const entry = {
2021
],
2122
};
2223

23-
const rules = (config.module as webpack.NewModule).rules.map((loaderConf: any) => {
24+
const rules = (config.module as webpack.ModuleOptions).rules?.map((loaderConf: any) => {
2425
if (loaderConf.test.test('test.ts')) {
2526
return {
2627
...loaderConf,
@@ -40,25 +41,20 @@ const module = {
4041
rules,
4142
};
4243

43-
const plugins = [
44-
...(config.plugins || []),
45-
new webpack.DefinePlugin({
46-
'process.env.NODE_ENV': 'null',
47-
}),
48-
new webpack.HotModuleReplacementPlugin(),
49-
];
50-
51-
const hotConfig = {
44+
const hotConfig: webpack.Configuration = {
5245
...config,
46+
mode: 'development',
5347
entry,
5448
module,
55-
plugins,
56-
devtool: '#cheap-module-source-map',
49+
devtool: 'cheap-module-source-map',
50+
stats: 'minimal',
51+
optimization: {
52+
runtimeChunk: 'single',
53+
},
5754
devServer: {
58-
contentBase: CONSTANTS.DOCS_DIR,
55+
static: CONSTANTS.DOCS_DIR,
5956
historyApiFallback: true,
6057
hot: true,
61-
stats: 'minimal',
6258
host: '0.0.0.0',
6359
port: CONSTANTS.DEV_SERVER_PORT,
6460
open: true,

0 commit comments

Comments
 (0)