Skip to content

Commit 817259d

Browse files
committed
Better Package
1 parent ca3ecec commit 817259d

File tree

11 files changed

+1788
-161
lines changed

11 files changed

+1788
-161
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
33
.vscode
4+
over

build/webpack.config.js

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
const path = require("path");
22
const HtmlWebpackPlugin = require("html-webpack-plugin");
33
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
5+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
6+
const CopyWebpackPlugin = require('copy-webpack-plugin');
7+
const CleanWebPackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin;
8+
const UglifyParallelPlugin = require('webpack-parallel-uglify-plugin');
49

510
module.exports = {
611
entry: {
7-
main: "./src/main.ts",
12+
seaper: "./src/main.ts",
813
},
914
output: {
10-
filename: "[name].js",
15+
filename: "js/[name].bundle.js",
1116
path: path.join(__dirname, "../dist"),
1217
},
1318
module: {
@@ -35,12 +40,64 @@ module.exports = {
3540
resolve: {
3641
extensions: [".tsx", ".ts", ".js"],
3742
},
43+
optimization: {
44+
splitChunks: {
45+
chunks: 'all',
46+
cacheGroups: {
47+
rc: {
48+
name: "rc",
49+
test: (module) => (/rc-/.test(module.context)),
50+
priority: 4
51+
},
52+
react: {
53+
name: "react",
54+
test: (module) => (/react/.test(module.context) || /redux/.test(module.context)
55+
|| /classnames/.test(module.context) || /prop-types/.test(module.context)),
56+
priority: 3
57+
},
58+
antd: {
59+
name: "antd",
60+
test: (module) => (/antd/.test(module.context) || /ant-design/.test(module.context)),
61+
priority: 2
62+
},
63+
default: {
64+
name: "other",
65+
test: (module) => (/node_modules/.test(module.context)),
66+
priority: 1
67+
}
68+
}
69+
},
70+
runtimeChunk: {
71+
name: entrypoint => `rt-${entrypoint.name}`
72+
},
73+
minimizer:[
74+
new CssMinimizerPlugin(),
75+
]
76+
},
3877
plugins: [
3978
new HtmlWebpackPlugin({
40-
template: "./public/index.html",
79+
template: "./index.html",
80+
filename: './index.html',
81+
chunks: "all"
82+
}),
83+
new MiniCssExtractPlugin(),
84+
new BundleAnalyzerPlugin(),
85+
new CopyWebpackPlugin({
86+
patterns: [
87+
{
88+
from: path.resolve(__dirname, '../public'),
89+
to: path.resolve(__dirname, '../dist'),
90+
}
91+
]
4192
}),
42-
new MiniCssExtractPlugin({
43-
filename: "main.css"
93+
new CleanWebPackPlugin(),
94+
new UglifyParallelPlugin({
95+
uglifyJS: {
96+
output: {
97+
beautify: false,
98+
comments: false
99+
}
100+
}
44101
})
45102
],
46103
mode: "production",

public/index.html renamed to index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" />
55
<link rel="icon" href="favicon.ico" />
66
<title>Seaper Server Manager</title>
7-
<link rel="stylesheet" href="./icon/iconfont.css" />
7+
<link rel="stylesheet" href="./font/iconfont.css" />
88
<link rel="stylesheet" href="./font/font.css" />
99
</head>
1010
<body>

0 commit comments

Comments
 (0)