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.
Files changed (66) hide show
  1. package/.eslintignore +30 -0
  2. package/.eslintrc.cjs +127 -0
  3. package/.npmignore +65 -0
  4. package/.prettierrc.cjs +14 -0
  5. package/LICENSE +8 -0
  6. package/LICENSE_CN +8 -0
  7. package/README +19 -0
  8. package/README_EN +19 -0
  9. package/REEPORT +15 -0
  10. package/REPORT_EN +15 -0
  11. package/config.json +5 -0
  12. package/package.json +65 -0
  13. package/public/.__ignore__ +1 -0
  14. package/src/404.js +1 -0
  15. package/src/4xx.js +1 -0
  16. package/src/5xx.js +1 -0
  17. package/src/assets/image/logo.png +0 -0
  18. package/src/assets/image/logo_big.png +0 -0
  19. package/src/assets/image/songzihuan.jpg +0 -0
  20. package/src/assets/image/wangan.png +0 -0
  21. package/src/common.js +24 -0
  22. package/src/html/LICENSE_CN.html +48 -0
  23. package/src/html/LICENSE_US.html +46 -0
  24. package/src/html/error/4xx/400.html +12 -0
  25. package/src/html/error/4xx/403.html +13 -0
  26. package/src/html/error/4xx/404.html +19 -0
  27. package/src/html/error/4xx/404.signal.html +57 -0
  28. package/src/html/error/4xx/404.songzihuan.signal.html +58 -0
  29. package/src/html/error/4xx/405.html +13 -0
  30. package/src/html/error/4xx/4xx.html +13 -0
  31. package/src/html/error/5xx/500.html +13 -0
  32. package/src/html/error/5xx/500.signal.html +30 -0
  33. package/src/html/error/5xx/500.songzihuan.signal.html +31 -0
  34. package/src/html/error/5xx/501.html +13 -0
  35. package/src/html/error/5xx/502.html +12 -0
  36. package/src/html/error/5xx/503.html +13 -0
  37. package/src/html/error/5xx/504.html +12 -0
  38. package/src/html/error/5xx/505.html +13 -0
  39. package/src/html/error/5xx/506.html +12 -0
  40. package/src/html/error/5xx/507.html +13 -0
  41. package/src/html/error/5xx/508.html +13 -0
  42. package/src/html/error/5xx/509.html +13 -0
  43. package/src/html/error/5xx/510.html +12 -0
  44. package/src/html/error/5xx/511.html +15 -0
  45. package/src/html/error/5xx/5xx.html +13 -0
  46. package/src/html/index.html +85 -0
  47. package/src/html/index.new.html +16 -0
  48. package/src/html/index.new.signal.html +43 -0
  49. package/src/html/mitorg.html +5073 -0
  50. package/src/index.js +1 -0
  51. package/src/license.js +1 -0
  52. package/src/main.js +0 -0
  53. package/src/mitorg.js +1 -0
  54. package/src/new.js +1 -0
  55. package/src/signal.js +1 -0
  56. package/src/style/error/404.css +31 -0
  57. package/src/style/error/4xx.css +17 -0
  58. package/src/style/error/5xx.css +15 -0
  59. package/src/style/index/index.css +26 -0
  60. package/src/style/index/license.css +4 -0
  61. package/src/style/index/mitorg.css +106 -0
  62. package/src/style/index/new.css +22 -0
  63. package/src/utils/file.js +45 -0
  64. package/webpack_config_dev.js +258 -0
  65. package/webpack_config_github.js +293 -0
  66. package/webpack_config_prod.js +278 -0
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ import '/src/style/index/index.css'
package/src/license.js ADDED
@@ -0,0 +1 @@
1
+ import '/src/style/index/license.css'
package/src/main.js ADDED
File without changes
package/src/mitorg.js ADDED
@@ -0,0 +1 @@
1
+ import '/src/style/index/mitorg.css'
package/src/new.js ADDED
@@ -0,0 +1 @@
1
+ import '/src/style/index/new.css'
package/src/signal.js ADDED
@@ -0,0 +1 @@
1
+ // 空白,无任何引入
@@ -0,0 +1,31 @@
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ text-align: center;
4
+ padding-top: 50px;
5
+ background-color: #f8f8f8;
6
+ }
7
+
8
+ h1 {
9
+ font-size: 7em;
10
+ margin-bottom: 0.5em;
11
+ color: #cc0000;
12
+ }
13
+
14
+ h2 {
15
+ font-size: 2em;
16
+ color: #666;
17
+ }
18
+
19
+ p {
20
+ font-size: 1.2em;
21
+ color: #333;
22
+ }
23
+
24
+ a {
25
+ color: #007bff;
26
+ text-decoration: none;
27
+ }
28
+
29
+ a:hover {
30
+ text-decoration: underline;
31
+ }
@@ -0,0 +1,17 @@
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ text-align: center;
4
+ padding-top: 50px;
5
+ background-color: #f8f9fa;
6
+ }
7
+
8
+ h1 {
9
+ font-size: 4em;
10
+ margin-bottom: 10px;
11
+ color: #dc3545;
12
+ }
13
+
14
+ p {
15
+ font-size: 1.5em;
16
+ color: #6c757d;
17
+ }
@@ -0,0 +1,15 @@
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ text-align: center;
4
+ margin-top: 50px;
5
+ }
6
+
7
+ h1 {
8
+ font-size: 3em;
9
+ color: #990000;
10
+ }
11
+
12
+ p {
13
+ font-size: 1.5em;
14
+ color: #666;
15
+ }
@@ -0,0 +1,26 @@
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ text-align: center;
4
+ padding-top: 50px;
5
+ background-color: #f0f0f0;
6
+ }
7
+
8
+ h1 {
9
+ color: #333;
10
+ margin-bottom: 20px;
11
+ }
12
+
13
+ a {
14
+ color: #007BFF;
15
+ text-decoration: none;
16
+ transition: color 0.3s ease;
17
+ }
18
+
19
+ a:hover {
20
+ color: #0056b3;
21
+ }
22
+
23
+ p {
24
+ color: #666;
25
+ line-height: 1.5;
26
+ }
@@ -0,0 +1,4 @@
1
+ #license-content {
2
+ white-space: pre-wrap;
3
+ width: 80ch;
4
+ }
@@ -0,0 +1,106 @@
1
+ @import url(https://fonts.googleapis.com/css?family=Inconsolata);html {
2
+ background: #eee
3
+ }
4
+
5
+ body {
6
+ margin: 0;
7
+ font-family: Inconsolata,"DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
8
+ font-size: 1.2em;
9
+ line-height: 1.2em
10
+ }
11
+
12
+ article,footer {
13
+ display: block;
14
+ min-width: 360px;
15
+ max-width: 900px;
16
+ width: 80%
17
+ }
18
+
19
+ article {
20
+ margin: 2.5em auto 0 auto;
21
+ border: 1px solid;
22
+ border-color: #ddd #aaa #aaa #ddd;
23
+ padding: 2em;
24
+ background: #fff
25
+ }
26
+
27
+ h1 {
28
+ margin-top: 0
29
+ }
30
+
31
+ article p:first-of-type {
32
+ margin-top: 1.6em
33
+ }
34
+
35
+ article p:last-child {
36
+ margin-bottom: 0
37
+ }
38
+
39
+ footer {
40
+ margin: 0 auto 2em auto;
41
+ text-align: center
42
+ }
43
+
44
+ footer a {
45
+ color: #666;
46
+ text-shadow: 0 1px 1px #fff;
47
+ text-decoration: none;
48
+ font-size: .8em;
49
+ padding: 1em
50
+ }
51
+
52
+ footer a:focus,footer a:hover {
53
+ color: #111
54
+ }
55
+
56
+ h1 {
57
+ font-weight: 400;
58
+ display: inline;
59
+ border-bottom: 1px solid #000;
60
+ padding: 0 0 3px 0;
61
+ line-height: 36px
62
+ }
63
+
64
+ a {
65
+ color: #2844fa;
66
+ text-decoration: none
67
+ }
68
+
69
+ a:focus,a:hover {
70
+ color: #1b29a4
71
+ }
72
+
73
+ a:active {
74
+ color: #000
75
+ }
76
+
77
+ :-moz-any-link:focus {
78
+ color: #000;
79
+ border: 0
80
+ }
81
+
82
+ ::-moz-selection {
83
+ background: #ccc
84
+ }
85
+
86
+ ::selection {
87
+ background: #ccc
88
+ }
89
+
90
+ #gravatar {
91
+ position: relative;
92
+ float: right;
93
+ margin-bottom: 1em;
94
+ margin-left: 1em;
95
+ border: 1px solid #ddd
96
+ }
97
+
98
+ @media all and (max-width: 500px) {
99
+ article {
100
+ padding:1em
101
+ }
102
+
103
+ body {
104
+ font-size: 1em
105
+ }
106
+ }
@@ -0,0 +1,22 @@
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ text-align: center;
4
+ padding-top: 50px;
5
+ background-color: #f0f8ff;
6
+ }
7
+
8
+ h1 {
9
+ color: #007bff;
10
+ margin-bottom: 30px;
11
+ }
12
+
13
+ p {
14
+ font-size: 18px;
15
+ line-height: 1.5;
16
+ }
17
+
18
+ .success-icon {
19
+ font-size: 100px;
20
+ color: #4CAF50;
21
+ margin-bottom: 20px;
22
+ }
@@ -0,0 +1,45 @@
1
+ import path from "path"
2
+ import fs from "fs"
3
+
4
+ export default {
5
+ getAllFilePaths
6
+ }
7
+
8
+ export function getAllFilePaths(dir) {
9
+ return _getAllFilePaths(dir, './', 5)
10
+ }
11
+
12
+ function _getAllFilePaths(filePath, localpath, deep) {
13
+ if (deep === 0) {
14
+ return [], []
15
+ }
16
+
17
+ let filePathResult = []
18
+ let localPathResult = []
19
+
20
+ // 读取目录中的所有文件和子目录
21
+ fs.readdirSync(filePath).forEach(function (file) {
22
+ const newFilePath = path.join(filePath, file)
23
+ const newLocalPath = path.join(localpath, file)
24
+
25
+ // 如果是目录,则递归读取该目录下的文件
26
+ if (fs.statSync(newFilePath).isDirectory()) {
27
+ const { filePathResult: _filrPath, localPathResult: _localPath } = _getAllFilePaths(
28
+ newFilePath,
29
+ newLocalPath,
30
+ deep - 1
31
+ )
32
+ filePathResult = filePathResult.concat(_filrPath)
33
+ localPathResult = localPathResult.concat(_localPath)
34
+ } else {
35
+ // 如果是文件,则直接加入结果数组
36
+ filePathResult.push(newFilePath)
37
+ localPathResult.push(newLocalPath)
38
+ }
39
+ })
40
+
41
+ return {
42
+ filePathResult,
43
+ localPathResult
44
+ }
45
+ }
@@ -0,0 +1,258 @@
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 = 'development'
12
+ const dist_name = 'dist-dev'
13
+
14
+ const HTMMLPlugin = []
15
+
16
+ const { localPathResult: AllHTMLLocalFile4xx } = filetool.getAllFilePaths(path.resolve(__dirname, 'src/html/error/4xx'))
17
+ AllHTMLLocalFile4xx.forEach((filePath) => {
18
+ if (!filePath.endsWith('.html')) {
19
+ return
20
+ }
21
+
22
+ if (filePath.includes('signal.html')) {
23
+ HTMMLPlugin.push(
24
+ new HtmlWebpackPlugin({
25
+ inject: 'body',
26
+ template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
27
+ filename: path.join('error/4xx', filePath),
28
+ chunks: ['signal'],
29
+ publicPath: '../../'
30
+ })
31
+ )
32
+ return
33
+ }
34
+
35
+ if (filePath.includes('400.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: ['common', 'err404'],
42
+ publicPath: '../../'
43
+ })
44
+ )
45
+ return
46
+ }
47
+
48
+ HTMMLPlugin.push(
49
+ new HtmlWebpackPlugin({
50
+ inject: 'body',
51
+ template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
52
+ filename: path.join('error/4xx', filePath),
53
+ chunks: ['common', 'err4xx'],
54
+ publicPath: '../../'
55
+ })
56
+ )
57
+ })
58
+
59
+ const { localPathResult: AllHTMLLocalFile5xx } = filetool.getAllFilePaths(path.resolve(__dirname, 'src/html/error/5xx'))
60
+ AllHTMLLocalFile5xx.forEach((filePath) => {
61
+ if (!filePath.endsWith('.html')) {
62
+ return
63
+ }
64
+
65
+ if (filePath.includes('signal.html')) {
66
+ HTMMLPlugin.push(
67
+ new HtmlWebpackPlugin({
68
+ inject: 'body',
69
+ template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
70
+ filename: path.join('error/5xx', filePath),
71
+ chunks: ['signal'],
72
+ publicPath: '../../'
73
+ })
74
+ )
75
+ return
76
+ }
77
+
78
+ HTMMLPlugin.push(
79
+ new HtmlWebpackPlugin({
80
+ inject: 'body',
81
+ template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
82
+ filename: path.join('error/5xx', filePath),
83
+ chunks: ['common', 'err5xx'],
84
+ publicPath: '../../'
85
+ })
86
+ )
87
+ })
88
+
89
+ const config = {
90
+ mode: mode,
91
+
92
+ context: __dirname,
93
+
94
+ performance: {
95
+ hints: 'warning', // 或者 'error',取决于你希望如何处理超出限制的情况
96
+ maxAssetSize: 5000000, // 设置单个资源的最大尺寸,例如5MB
97
+ maxEntrypointSize: 10000000 // 设置入口起点的最大尺寸,例如10MB
98
+ },
99
+
100
+ entry: {
101
+ common: path.resolve(__dirname, 'src/common.js'),
102
+ index: path.resolve(__dirname, 'src/index.js'),
103
+ signal: path.resolve(__dirname, 'src/signal.js'),
104
+ new: path.resolve(__dirname, 'src/new.js'),
105
+ license: path.resolve(__dirname, 'src/license.js'),
106
+ mitorg: path.resolve(__dirname, 'src/mitorg.js'),
107
+ err4xx: path.resolve(__dirname, 'src/4xx.js'),
108
+ err404: path.resolve(__dirname, 'src/404.js'),
109
+ err5xx: path.resolve(__dirname, 'src/5xx.js')
110
+ },
111
+
112
+ output: {
113
+ path: path.resolve(__dirname, dist_name), //打包后的文件存放的地方
114
+ filename: 'js/[name].[fullhash].bundle.js', //打包后输出文件的文件名
115
+ chunkFilename: '[name].bundle.js',
116
+ clean: true,
117
+ charset: true,
118
+ publicPath: '/'
119
+ },
120
+
121
+ resolve: {
122
+ alias: {
123
+ '@': path.join(__dirname, 'src')
124
+ }
125
+ },
126
+
127
+ module: {
128
+ rules: [
129
+ {
130
+ test: /\.(css|scss|sass)$/,
131
+ use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
132
+ },
133
+ {
134
+ test: /\.(png|jpg|jpeg|svg|gif)$/i,
135
+ use: [
136
+ {
137
+ loader: 'url-loader',
138
+ options: {
139
+ limit: 8192, // 8KB 以下的文件将被转换为 Data URL
140
+ fallback: 'file-loader',
141
+ outputPath: 'images', // 类似于 file-loader 的配置
142
+ name: '[name].[fullhash].[ext]'
143
+ }
144
+ }
145
+ ]
146
+ },
147
+ {
148
+ test: /\.(mp4|m4v|avi|mov|qt|wmv|mkv|flv|webm|mpeg|mpg|3gp|3g2)$/i,
149
+ use: [
150
+ {
151
+ loader: 'url-loader',
152
+ options: {
153
+ limit: 8192, // 8KB 以下的文件将被转换为 Data URL
154
+ fallback: 'file-loader',
155
+ outputPath: 'videos', // 类似于 file-loader 的配置
156
+ name: '[name].[fullhash].[ext]'
157
+ }
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
163
+ use: [
164
+ {
165
+ loader: 'url-loader',
166
+ options: {
167
+ limit: 8192, // 8KB 以下的文件将被转换为 Data URL
168
+ fallback: 'file-loader',
169
+ outputPath: 'fonts', // 类似于 file-loader 的配置
170
+ name: '[name].[fullhash].[ext]'
171
+ }
172
+ }
173
+ ]
174
+ },
175
+ {
176
+ test: /\.html$/i,
177
+ loader: 'html-loader'
178
+ }
179
+ ]
180
+ },
181
+
182
+ plugins: [
183
+ new CopyWebpackPlugin({
184
+ patterns: [
185
+ { from: 'public', to: './' },
186
+ { from: './config.json', to: './SH_CONFIG.json' },
187
+ { from: './LICENSE', to: './' },
188
+ { from: './LICENSE_CN', to: './' }
189
+ ]
190
+ }),
191
+ ...HTMMLPlugin,
192
+ new HtmlWebpackPlugin({
193
+ inject: 'body',
194
+ template: path.resolve(__dirname, 'src', 'html', 'index.html'), //指定模板文件
195
+ filename: 'index.html',
196
+ chunks: ['common', 'index'],
197
+ publicPath: './'
198
+ }),
199
+ new HtmlWebpackPlugin({
200
+ inject: 'body',
201
+ template: path.resolve(__dirname, 'src/html/LICENSE_US.html'), //指定模板文件
202
+ filename: 'LICENSE_US.html',
203
+ chunks: ['common', 'license'],
204
+ publicPath: './'
205
+ }),
206
+ new HtmlWebpackPlugin({
207
+ inject: 'body',
208
+ template: path.resolve(__dirname, 'src/html/LICENSE_CN.html'), //指定模板文件
209
+ filename: 'LICENSE_CN.html',
210
+ chunks: ['common', 'license'],
211
+ publicPath: './'
212
+ }),
213
+ new HtmlWebpackPlugin({
214
+ inject: 'body',
215
+ template: path.resolve(__dirname, 'src/html/mitorg.html'), //指定模板文件
216
+ filename: 'mitorg.html',
217
+ chunks: ['common', 'mitorg'],
218
+ publicPath: './'
219
+ }),
220
+ new HtmlWebpackPlugin({
221
+ inject: 'body',
222
+ template: path.resolve(__dirname, 'src/html/index.new.signal.html'), //指定模板文件
223
+ filename: 'index.new.signal.html',
224
+ chunks: ['common', 'new', 'signal'], // 此signal要设置common
225
+ publicPath: './'
226
+ }),
227
+ new HtmlWebpackPlugin({
228
+ inject: 'body',
229
+ template: path.resolve(__dirname, 'src/html/index.new.html'), //指定模板文件
230
+ filename: 'index.new.html',
231
+ chunks: ['common', 'new'],
232
+ publicPath: './'
233
+ }),
234
+ new HtmlWebpackPlugin({
235
+ inject: 'body',
236
+ template: path.resolve(__dirname, 'src/html/error/4xx/404.signal.html'), //指定模板文件
237
+ filename: '404.html',
238
+ chunks: ['common', 'signal'], // 该signal要设置common
239
+ publicPath: './'
240
+ }),
241
+ new MiniCssExtractPlugin({
242
+ filename: 'style/[name].[fullhash].bundle.css',
243
+ chunkFilename: 'css/[id].bundle.css'
244
+ })
245
+ ],
246
+
247
+ devServer: {
248
+ static: {
249
+ directory: path.join(__dirname, dist_name)
250
+ },
251
+ compress: true,
252
+ port: 1001,
253
+ open: true,
254
+ hot: true
255
+ }
256
+ }
257
+
258
+ export default config