huan-simple-html 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +30 -0
- package/.eslintrc.cjs +127 -0
- package/.npmignore +65 -0
- package/.prettierrc.cjs +14 -0
- package/LICENSE +8 -0
- package/LICENSE_CN +8 -0
- package/README +19 -0
- package/README_EN +19 -0
- package/REEPORT +15 -0
- package/REPORT_EN +15 -0
- package/config.json +5 -0
- package/package.json +65 -0
- package/public/.__ignore__ +1 -0
- package/src/404.js +1 -0
- package/src/4xx.js +1 -0
- package/src/5xx.js +1 -0
- package/src/assets/image/logo.png +0 -0
- package/src/assets/image/logo_big.png +0 -0
- package/src/assets/image/songzihuan.jpg +0 -0
- package/src/assets/image/wangan.png +0 -0
- package/src/common.js +24 -0
- package/src/html/LICENSE_CN.html +48 -0
- package/src/html/LICENSE_US.html +46 -0
- package/src/html/error/4xx/400.html +12 -0
- package/src/html/error/4xx/403.html +13 -0
- package/src/html/error/4xx/404.html +19 -0
- package/src/html/error/4xx/404.signal.html +57 -0
- package/src/html/error/4xx/404.songzihuan.signal.html +58 -0
- package/src/html/error/4xx/405.html +13 -0
- package/src/html/error/4xx/4xx.html +13 -0
- package/src/html/error/5xx/500.html +13 -0
- package/src/html/error/5xx/500.signal.html +30 -0
- package/src/html/error/5xx/500.songzihuan.signal.html +31 -0
- package/src/html/error/5xx/501.html +13 -0
- package/src/html/error/5xx/502.html +12 -0
- package/src/html/error/5xx/503.html +13 -0
- package/src/html/error/5xx/504.html +12 -0
- package/src/html/error/5xx/505.html +13 -0
- package/src/html/error/5xx/506.html +12 -0
- package/src/html/error/5xx/507.html +13 -0
- package/src/html/error/5xx/508.html +13 -0
- package/src/html/error/5xx/509.html +13 -0
- package/src/html/error/5xx/510.html +12 -0
- package/src/html/error/5xx/511.html +15 -0
- package/src/html/error/5xx/5xx.html +13 -0
- package/src/html/index.html +85 -0
- package/src/html/index.new.html +16 -0
- package/src/html/index.new.signal.html +43 -0
- package/src/html/mitorg.html +5073 -0
- package/src/index.js +1 -0
- package/src/license.js +1 -0
- package/src/main.js +0 -0
- package/src/mitorg.js +1 -0
- package/src/new.js +1 -0
- package/src/signal.js +1 -0
- package/src/style/error/404.css +31 -0
- package/src/style/error/4xx.css +17 -0
- package/src/style/error/5xx.css +15 -0
- package/src/style/index/index.css +26 -0
- package/src/style/index/license.css +4 -0
- package/src/style/index/mitorg.css +106 -0
- package/src/style/index/new.css +22 -0
- package/src/utils/file.js +45 -0
- package/webpack_config_dev.js +258 -0
- package/webpack_config_github.js +293 -0
- package/webpack_config_prod.js +278 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
+
import CopyWebpackPlugin from "copy-webpack-plugin"
|
|
5
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
6
|
+
import filetool from './src/utils/file.js'
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
|
|
12
|
+
const mode = 'production'
|
|
13
|
+
const dist_name = 'docs'
|
|
14
|
+
|
|
15
|
+
const html_minify = {
|
|
16
|
+
collapseWhitespace: true,
|
|
17
|
+
removeComments: true,
|
|
18
|
+
removeRedundantAttributes: true,
|
|
19
|
+
useShortDoctype: true,
|
|
20
|
+
removeEmptyAttributes: true,
|
|
21
|
+
removeStyleLinkTypeAttributes: true,
|
|
22
|
+
keepClosingSlash: true,
|
|
23
|
+
minifyJS: true,
|
|
24
|
+
minifyCSS: true,
|
|
25
|
+
minifyURLs: true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const HTMMLPlugin = []
|
|
29
|
+
|
|
30
|
+
const { localPathResult: AllHTMLLocalFile4xx } = filetool.getAllFilePaths(path.resolve(__dirname, 'src/html/error/4xx'))
|
|
31
|
+
AllHTMLLocalFile4xx.forEach((filePath) => {
|
|
32
|
+
if (!filePath.endsWith('.html')) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (filePath.includes('signal')) {
|
|
37
|
+
HTMMLPlugin.push(
|
|
38
|
+
new HtmlWebpackPlugin({
|
|
39
|
+
inject: 'body',
|
|
40
|
+
template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
41
|
+
filename: path.join('error/4xx', filePath),
|
|
42
|
+
chunks: ['signal'],
|
|
43
|
+
publicPath: '../../'
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (filePath.includes('404')) {
|
|
50
|
+
HTMMLPlugin.push(
|
|
51
|
+
new HtmlWebpackPlugin({
|
|
52
|
+
inject: 'body',
|
|
53
|
+
template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
54
|
+
filename: path.join('error/4xx', filePath),
|
|
55
|
+
chunks: ['common', 'err404'],
|
|
56
|
+
publicPath: '../../'
|
|
57
|
+
})
|
|
58
|
+
)
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
HTMMLPlugin.push(
|
|
63
|
+
new HtmlWebpackPlugin({
|
|
64
|
+
inject: 'body',
|
|
65
|
+
template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
66
|
+
filename: path.join('error/4xx', filePath),
|
|
67
|
+
chunks: ['common', 'err4xx'],
|
|
68
|
+
publicPath: '../../'
|
|
69
|
+
})
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const { localPathResult: AllHTMLLocalFile5xx } = filetool.getAllFilePaths(path.resolve(__dirname, 'src/html/error/5xx'))
|
|
74
|
+
AllHTMLLocalFile5xx.forEach((filePath) => {
|
|
75
|
+
if (!filePath.endsWith('.html')) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (filePath.includes('signal')) {
|
|
80
|
+
HTMMLPlugin.push(
|
|
81
|
+
new HtmlWebpackPlugin({
|
|
82
|
+
inject: 'body',
|
|
83
|
+
template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
|
|
84
|
+
filename: path.join('error/5xx', filePath),
|
|
85
|
+
chunks: ['signal'],
|
|
86
|
+
publicPath: '../../'
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
HTMMLPlugin.push(
|
|
93
|
+
new HtmlWebpackPlugin({
|
|
94
|
+
inject: 'body',
|
|
95
|
+
template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
|
|
96
|
+
filename: path.join('error/5xx', filePath),
|
|
97
|
+
chunks: ['common', 'err5xx'],
|
|
98
|
+
publicPath: '../../'
|
|
99
|
+
})
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const config = {
|
|
104
|
+
mode: mode,
|
|
105
|
+
|
|
106
|
+
context: __dirname,
|
|
107
|
+
|
|
108
|
+
performance: {
|
|
109
|
+
hints: 'warning', // 或者 'error',取决于你希望如何处理超出限制的情况
|
|
110
|
+
maxAssetSize: 5000000, // 设置单个资源的最大尺寸,例如5MB
|
|
111
|
+
maxEntrypointSize: 10000000 // 设置入口起点的最大尺寸,例如10MB
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
entry: {
|
|
115
|
+
common: path.resolve(__dirname, 'src/common.js'),
|
|
116
|
+
index: path.resolve(__dirname, 'src/index.js'),
|
|
117
|
+
signal: path.resolve(__dirname, 'src/signal.js'),
|
|
118
|
+
new: path.resolve(__dirname, 'src/new.js'),
|
|
119
|
+
license: path.resolve(__dirname, 'src/license.js'),
|
|
120
|
+
mitorg: path.resolve(__dirname, 'src/mitorg.js'),
|
|
121
|
+
err4xx: path.resolve(__dirname, 'src/4xx.js'),
|
|
122
|
+
err404: path.resolve(__dirname, 'src/404.js'),
|
|
123
|
+
err5xx: path.resolve(__dirname, 'src/5xx.js')
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
output: {
|
|
127
|
+
path: path.resolve(__dirname, dist_name), //打包后的文件存放的地方
|
|
128
|
+
filename: 'js/[name].[fullhash].bundle.js', //打包后输出文件的文件名
|
|
129
|
+
chunkFilename: '[name].bundle.js',
|
|
130
|
+
clean: true,
|
|
131
|
+
charset: true,
|
|
132
|
+
publicPath: '/'
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
resolve: {
|
|
136
|
+
alias: {
|
|
137
|
+
'@': path.join(__dirname, 'src')
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
optimization: {
|
|
142
|
+
minimize: true,
|
|
143
|
+
minimizer: [
|
|
144
|
+
new TerserPlugin({
|
|
145
|
+
terserOptions: {
|
|
146
|
+
compress: {
|
|
147
|
+
drop_console: true, // 移除console.log (Github/发布版专属)
|
|
148
|
+
drop_debugger: true // 移除debugger (Github/发布版专属)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
module: {
|
|
156
|
+
rules: [
|
|
157
|
+
{
|
|
158
|
+
test: /\.(css|scss|sass)$/,
|
|
159
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
test: /\.(png|jpg|jpeg|svg|gif)$/i,
|
|
163
|
+
use: [
|
|
164
|
+
{
|
|
165
|
+
loader: 'url-loader',
|
|
166
|
+
options: {
|
|
167
|
+
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
168
|
+
fallback: 'file-loader',
|
|
169
|
+
outputPath: 'images', // 类似于 file-loader 的配置
|
|
170
|
+
name: '[name].[fullhash].[ext]'
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
test: /\.(mp4|m4v|avi|mov|qt|wmv|mkv|flv|webm|mpeg|mpg|3gp|3g2)$/i,
|
|
177
|
+
use: [
|
|
178
|
+
{
|
|
179
|
+
loader: 'url-loader',
|
|
180
|
+
options: {
|
|
181
|
+
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
182
|
+
fallback: 'file-loader',
|
|
183
|
+
outputPath: 'videos', // 类似于 file-loader 的配置
|
|
184
|
+
name: '[name].[fullhash].[ext]'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
191
|
+
use: [
|
|
192
|
+
{
|
|
193
|
+
loader: 'url-loader',
|
|
194
|
+
options: {
|
|
195
|
+
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
196
|
+
fallback: 'file-loader',
|
|
197
|
+
outputPath: 'fonts', // 类似于 file-loader 的配置
|
|
198
|
+
name: '[name].[fullhash].[ext]'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
test: /\.html$/i,
|
|
205
|
+
loader: 'html-loader'
|
|
206
|
+
},
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
plugins: [
|
|
211
|
+
new CopyWebpackPlugin({
|
|
212
|
+
patterns: [
|
|
213
|
+
{ from: 'public', to: './' },
|
|
214
|
+
{ from: './config.json', to: './SH_CONFIG.json' },
|
|
215
|
+
{ from: './LICENSE', to: './' },
|
|
216
|
+
{ from: './LICENSE_CN', to: './' }
|
|
217
|
+
]
|
|
218
|
+
}),
|
|
219
|
+
...HTMMLPlugin,
|
|
220
|
+
new HtmlWebpackPlugin({
|
|
221
|
+
inject: 'body',
|
|
222
|
+
template: path.resolve(__dirname, 'src', 'html', 'index.html'), //指定模板文件
|
|
223
|
+
filename: 'index.html',
|
|
224
|
+
chunks: ['common', 'index'],
|
|
225
|
+
minify: html_minify,
|
|
226
|
+
publicPath: './'
|
|
227
|
+
}),
|
|
228
|
+
new HtmlWebpackPlugin({
|
|
229
|
+
inject: 'body',
|
|
230
|
+
template: path.resolve(__dirname, 'src', 'html', 'LICENSE_US.html'), //指定模板文件
|
|
231
|
+
filename: 'LICENSE_US.html',
|
|
232
|
+
chunks: ['common', 'license'],
|
|
233
|
+
minify: html_minify,
|
|
234
|
+
publicPath: './'
|
|
235
|
+
}),
|
|
236
|
+
new HtmlWebpackPlugin({
|
|
237
|
+
inject: 'body',
|
|
238
|
+
template: path.resolve(__dirname, 'src', 'html', 'LICENSE_CN.html'), //指定模板文件
|
|
239
|
+
filename: 'LICENSE_CN.html',
|
|
240
|
+
chunks: ['common', 'license'],
|
|
241
|
+
minify: html_minify,
|
|
242
|
+
publicPath: './'
|
|
243
|
+
}),
|
|
244
|
+
new HtmlWebpackPlugin({
|
|
245
|
+
inject: 'body',
|
|
246
|
+
template: path.resolve(__dirname, 'src', 'html', 'mitorg.html'), //指定模板文件
|
|
247
|
+
filename: 'mitorg.html',
|
|
248
|
+
chunks: ['common', 'mitorg'],
|
|
249
|
+
minify: html_minify,
|
|
250
|
+
publicPath: './'
|
|
251
|
+
}),
|
|
252
|
+
new HtmlWebpackPlugin({
|
|
253
|
+
inject: 'body',
|
|
254
|
+
template: path.resolve(__dirname, 'src', 'html', 'index.new.signal.html'), //指定模板文件
|
|
255
|
+
filename: 'index.new.signal.html',
|
|
256
|
+
chunks: ['common', 'new', 'signal'], // 此signal要设置common
|
|
257
|
+
minify: html_minify,
|
|
258
|
+
publicPath: './'
|
|
259
|
+
}),
|
|
260
|
+
new HtmlWebpackPlugin({
|
|
261
|
+
inject: 'body',
|
|
262
|
+
template: path.resolve(__dirname, 'src', 'html', 'index.new.html'), //指定模板文件
|
|
263
|
+
filename: 'index.new.html',
|
|
264
|
+
chunks: ['common', 'new'],
|
|
265
|
+
minify: html_minify,
|
|
266
|
+
publicPath: './'
|
|
267
|
+
}),
|
|
268
|
+
new HtmlWebpackPlugin({
|
|
269
|
+
inject: 'body',
|
|
270
|
+
template: path.resolve(__dirname, 'src/html/error/4xx/404.signal.html'), //指定模板文件
|
|
271
|
+
filename: '404.html',
|
|
272
|
+
chunks: ['common', 'signal'], // 此signal要设置common
|
|
273
|
+
minify: html_minify,
|
|
274
|
+
publicPath: './'
|
|
275
|
+
}),
|
|
276
|
+
new MiniCssExtractPlugin({
|
|
277
|
+
filename: 'style/[name].[hash].bundle.css',
|
|
278
|
+
chunkFilename: 'css/[id].bundle.css'
|
|
279
|
+
})
|
|
280
|
+
],
|
|
281
|
+
|
|
282
|
+
devServer: {
|
|
283
|
+
static: {
|
|
284
|
+
directory: path.join(__dirname, dist_name)
|
|
285
|
+
},
|
|
286
|
+
compress: true,
|
|
287
|
+
port: 1001,
|
|
288
|
+
open: true,
|
|
289
|
+
hot: false
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export default config
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
+
import CopyWebpackPlugin from "copy-webpack-plugin"
|
|
5
|
+
import filetool from './src/utils/file.js'
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const mode = 'production'
|
|
12
|
+
const dist_name = 'dist-prod'
|
|
13
|
+
|
|
14
|
+
const html_minify = {
|
|
15
|
+
collapseWhitespace: true,
|
|
16
|
+
removeComments: true,
|
|
17
|
+
removeRedundantAttributes: true,
|
|
18
|
+
useShortDoctype: true,
|
|
19
|
+
removeEmptyAttributes: true,
|
|
20
|
+
removeStyleLinkTypeAttributes: true,
|
|
21
|
+
keepClosingSlash: true,
|
|
22
|
+
minifyJS: true,
|
|
23
|
+
minifyCSS: true,
|
|
24
|
+
minifyURLs: true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const HTMMLPlugin = []
|
|
28
|
+
|
|
29
|
+
const { localPathResult: AllHTMLLocalFile4xx } = filetool.getAllFilePaths(path.resolve(__dirname, 'src/html/error/4xx'))
|
|
30
|
+
AllHTMLLocalFile4xx.forEach((filePath) => {
|
|
31
|
+
if (!filePath.endsWith('.html')) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (filePath.includes('signal.html')) {
|
|
36
|
+
HTMMLPlugin.push(
|
|
37
|
+
new HtmlWebpackPlugin({
|
|
38
|
+
inject: 'body',
|
|
39
|
+
template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
40
|
+
filename: path.join('error/4xx', filePath),
|
|
41
|
+
chunks: ['signal'],
|
|
42
|
+
publicPath: '../../'
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (filePath.includes('400.html')) {
|
|
49
|
+
HTMMLPlugin.push(
|
|
50
|
+
new HtmlWebpackPlugin({
|
|
51
|
+
inject: 'body',
|
|
52
|
+
template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
53
|
+
filename: path.join('error/4xx', filePath),
|
|
54
|
+
chunks: ['common', 'err404'],
|
|
55
|
+
publicPath: '../../'
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
HTMMLPlugin.push(
|
|
62
|
+
new HtmlWebpackPlugin({
|
|
63
|
+
inject: 'body',
|
|
64
|
+
template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
65
|
+
filename: path.join('error/4xx', filePath),
|
|
66
|
+
chunks: ['common', 'err4xx'],
|
|
67
|
+
publicPath: '../../'
|
|
68
|
+
})
|
|
69
|
+
)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const { localPathResult: AllHTMLLocalFile5xx } = filetool.getAllFilePaths(path.resolve(__dirname, 'src/html/error/5xx'))
|
|
73
|
+
AllHTMLLocalFile5xx.forEach((filePath) => {
|
|
74
|
+
if (!filePath.endsWith('.html')) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (filePath.includes('signal.html')) {
|
|
79
|
+
HTMMLPlugin.push(
|
|
80
|
+
new HtmlWebpackPlugin({
|
|
81
|
+
inject: 'body',
|
|
82
|
+
template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
|
|
83
|
+
filename: path.join('error/5xx', filePath),
|
|
84
|
+
chunks: ['signal'],
|
|
85
|
+
publicPath: '../../'
|
|
86
|
+
})
|
|
87
|
+
)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
HTMMLPlugin.push(
|
|
92
|
+
new HtmlWebpackPlugin({
|
|
93
|
+
inject: 'body',
|
|
94
|
+
template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
|
|
95
|
+
filename: path.join('error/5xx', filePath),
|
|
96
|
+
chunks: ['common', 'err5xx'],
|
|
97
|
+
publicPath: '../../'
|
|
98
|
+
})
|
|
99
|
+
)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const config = {
|
|
103
|
+
mode: mode,
|
|
104
|
+
|
|
105
|
+
context: __dirname,
|
|
106
|
+
|
|
107
|
+
performance: {
|
|
108
|
+
hints: 'warning', // 或者 'error',取决于你希望如何处理超出限制的情况
|
|
109
|
+
maxAssetSize: 5000000, // 设置单个资源的最大尺寸,例如5MB
|
|
110
|
+
maxEntrypointSize: 10000000 // 设置入口起点的最大尺寸,例如10MB
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
entry: {
|
|
114
|
+
common: path.resolve(__dirname, 'src/common.js'),
|
|
115
|
+
index: path.resolve(__dirname, 'src/index.js'),
|
|
116
|
+
signal: path.resolve(__dirname, 'src/signal.js'),
|
|
117
|
+
new: path.resolve(__dirname, 'src/new.js'),
|
|
118
|
+
license: path.resolve(__dirname, 'src/license.js'),
|
|
119
|
+
mitorg: path.resolve(__dirname, 'src/mitorg.js'),
|
|
120
|
+
err4xx: path.resolve(__dirname, 'src/4xx.js'),
|
|
121
|
+
err404: path.resolve(__dirname, 'src/404.js'),
|
|
122
|
+
err5xx: path.resolve(__dirname, 'src/5xx.js')
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
output: {
|
|
126
|
+
path: path.resolve(__dirname, dist_name), //打包后的文件存放的地方
|
|
127
|
+
filename: 'js/[name].[fullhash].bundle.js', //打包后输出文件的文件名
|
|
128
|
+
chunkFilename: '[name].bundle.js',
|
|
129
|
+
clean: true,
|
|
130
|
+
charset: true,
|
|
131
|
+
publicPath: '/'
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
resolve: {
|
|
135
|
+
alias: {
|
|
136
|
+
'@': path.join(__dirname, 'src')
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
module: {
|
|
141
|
+
rules: [
|
|
142
|
+
{
|
|
143
|
+
test: /\.(css|scss|sass)$/,
|
|
144
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
test: /\.(png|jpg|jpeg|svg|gif)$/i,
|
|
148
|
+
use: [
|
|
149
|
+
{
|
|
150
|
+
loader: 'url-loader',
|
|
151
|
+
options: {
|
|
152
|
+
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
153
|
+
fallback: 'file-loader',
|
|
154
|
+
outputPath: 'images', // 类似于 file-loader 的配置
|
|
155
|
+
name: '[name].[fullhash].[ext]'
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
test: /\.(mp4|m4v|avi|mov|qt|wmv|mkv|flv|webm|mpeg|mpg|3gp|3g2)$/i,
|
|
162
|
+
use: [
|
|
163
|
+
{
|
|
164
|
+
loader: 'url-loader',
|
|
165
|
+
options: {
|
|
166
|
+
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
167
|
+
fallback: 'file-loader',
|
|
168
|
+
outputPath: 'videos', // 类似于 file-loader 的配置
|
|
169
|
+
name: '[name].[fullhash].[ext]'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
176
|
+
use: [
|
|
177
|
+
{
|
|
178
|
+
loader: 'url-loader',
|
|
179
|
+
options: {
|
|
180
|
+
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
181
|
+
fallback: 'file-loader',
|
|
182
|
+
outputPath: 'fonts', // 类似于 file-loader 的配置
|
|
183
|
+
name: '[name].[fullhash].[ext]'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
test: /\.html$/i,
|
|
190
|
+
loader: 'html-loader'
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
plugins: [
|
|
196
|
+
new CopyWebpackPlugin({
|
|
197
|
+
patterns: [
|
|
198
|
+
{ from: 'public', to: './' },
|
|
199
|
+
{ from: './config.json', to: './SH_CONFIG.json' },
|
|
200
|
+
{ from: './LICENSE', to: './' },
|
|
201
|
+
{ from: './LICENSE_CN', to: './' }
|
|
202
|
+
]
|
|
203
|
+
}),
|
|
204
|
+
...HTMMLPlugin,
|
|
205
|
+
new HtmlWebpackPlugin({
|
|
206
|
+
inject: 'body',
|
|
207
|
+
template: path.resolve(__dirname, 'src', 'html', 'index.html'), //指定模板文件
|
|
208
|
+
filename: 'index.html',
|
|
209
|
+
chunks: ['common', 'index'],
|
|
210
|
+
minify: html_minify,
|
|
211
|
+
publicPath: './'
|
|
212
|
+
}),
|
|
213
|
+
new HtmlWebpackPlugin({
|
|
214
|
+
inject: 'body',
|
|
215
|
+
template: path.resolve(__dirname, 'src', 'html', 'LICENSE_US.html'), //指定模板文件
|
|
216
|
+
filename: 'LICENSE_US.html',
|
|
217
|
+
chunks: ['common', 'license'],
|
|
218
|
+
minify: html_minify,
|
|
219
|
+
publicPath: './'
|
|
220
|
+
}),
|
|
221
|
+
new HtmlWebpackPlugin({
|
|
222
|
+
inject: 'body',
|
|
223
|
+
template: path.resolve(__dirname, 'src/html/LICENSE_CN.html'), //指定模板文件
|
|
224
|
+
filename: 'LICENSE_CN.html',
|
|
225
|
+
chunks: ['common', 'license'],
|
|
226
|
+
minify: html_minify,
|
|
227
|
+
publicPath: './'
|
|
228
|
+
}),
|
|
229
|
+
new HtmlWebpackPlugin({
|
|
230
|
+
inject: 'body',
|
|
231
|
+
template: path.resolve(__dirname, 'src', 'html', 'mitorg.html'), //指定模板文件
|
|
232
|
+
filename: 'mitorg.html',
|
|
233
|
+
chunks: ['common', 'mitorg'],
|
|
234
|
+
minify: html_minify,
|
|
235
|
+
publicPath: './'
|
|
236
|
+
}),
|
|
237
|
+
new HtmlWebpackPlugin({
|
|
238
|
+
inject: 'body',
|
|
239
|
+
template: path.resolve(__dirname, 'src', 'html', 'index.new.signal.html'), //指定模板文件
|
|
240
|
+
filename: 'index.new.signal.html',
|
|
241
|
+
chunks: ['common', 'new', 'signal'], // 此signal要设置common
|
|
242
|
+
minify: html_minify,
|
|
243
|
+
publicPath: './'
|
|
244
|
+
}),
|
|
245
|
+
new HtmlWebpackPlugin({
|
|
246
|
+
inject: 'body',
|
|
247
|
+
template: path.resolve(__dirname, 'src', 'html', 'index.new.html'), //指定模板文件
|
|
248
|
+
filename: 'index.new.html',
|
|
249
|
+
chunks: ['common', 'new'],
|
|
250
|
+
minify: html_minify,
|
|
251
|
+
publicPath: './'
|
|
252
|
+
}),
|
|
253
|
+
new HtmlWebpackPlugin({
|
|
254
|
+
inject: 'body',
|
|
255
|
+
template: path.resolve(__dirname, 'src/html/error/4xx/404.signal.html'), //指定模板文件
|
|
256
|
+
filename: '404.html',
|
|
257
|
+
chunks: ['common', 'signal'], // 此signal要设置common
|
|
258
|
+
minify: html_minify,
|
|
259
|
+
publicPath: './'
|
|
260
|
+
}),
|
|
261
|
+
new MiniCssExtractPlugin({
|
|
262
|
+
filename: 'style/[name].[hash].bundle.css',
|
|
263
|
+
chunkFilename: 'css/[id].bundle.css'
|
|
264
|
+
})
|
|
265
|
+
],
|
|
266
|
+
|
|
267
|
+
devServer: {
|
|
268
|
+
static: {
|
|
269
|
+
directory: path.join(__dirname, dist_name)
|
|
270
|
+
},
|
|
271
|
+
compress: true,
|
|
272
|
+
port: 1001,
|
|
273
|
+
open: true,
|
|
274
|
+
hot: true
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export default config
|