huan-simple-html 1.0.1 → 1.1.1
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/.eslintrc.cjs +1 -0
- package/.npmignore +6 -1
- package/babel_config.js +36 -0
- package/package.json +13 -5
- package/src/common.js +3 -3
- package/webpack_config_dev.js +22 -11
- package/webpack_config_github.js +24 -13
- package/webpack_config_prod.js +22 -11
- package/src/utils/file.js +0 -45
package/.eslintrc.cjs
CHANGED
package/.npmignore
CHANGED
package/babel_config.js
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
const config = {
|
2
|
+
presets: [
|
3
|
+
[
|
4
|
+
'@babel/preset-env', // 使用 @babel/preset-env 转换语法
|
5
|
+
{
|
6
|
+
// 目标环境配置,根据需要调整
|
7
|
+
targets: {
|
8
|
+
browsers: [
|
9
|
+
// 你可以指定具体的浏览器版本,例如:
|
10
|
+
// "last 2 versions",
|
11
|
+
// ">= 1%",
|
12
|
+
// "Chrome >= 49",
|
13
|
+
// "Firefox >= 45",
|
14
|
+
// 或使用 "defaults" 自动选择一组常见的浏览器版本
|
15
|
+
'defaults'
|
16
|
+
]
|
17
|
+
},
|
18
|
+
// 启用或禁用模块转换
|
19
|
+
modules: false, // 或 "auto" / "commonjs"
|
20
|
+
|
21
|
+
// 可选:按需加载 polyfills
|
22
|
+
useBuiltIns: 'usage', // 根据代码实际使用情况自动引入 polyfills
|
23
|
+
corejs: 3 // 如果使用按需加载,需要指定 core-js 的版本
|
24
|
+
|
25
|
+
// 可选:包含或排除特定的 transforms
|
26
|
+
// exclude: ['transform-regenerator'], // 例如,排除 regenerator 转换
|
27
|
+
// include: ['@babel/plugin-proposal-class-properties'], // 或者包含额外的提案特性
|
28
|
+
}
|
29
|
+
]
|
30
|
+
],
|
31
|
+
|
32
|
+
// 可选:包含全局的 Babel 插件
|
33
|
+
plugins: []
|
34
|
+
}
|
35
|
+
|
36
|
+
export default config
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "huan-simple-html",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.1",
|
4
4
|
"description": "一个简单的HTML项目,通过Webpack进行打包。请尽量使用pnpm处理此包。更多细节请查看\"README.md\"",
|
5
5
|
"keywords": [
|
6
6
|
"html",
|
@@ -25,7 +25,11 @@
|
|
25
25
|
"pnpm": ">=8"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
|
+
"@babel/core": "^7.26.0",
|
29
|
+
"@babel/preset-env": "^7.26.0",
|
30
|
+
"babel-loader": "^9.2.1",
|
28
31
|
"copy-webpack-plugin": "^12.0.2",
|
32
|
+
"core-js": "3",
|
29
33
|
"css-loader": "^7.1.2",
|
30
34
|
"eslint": "^8.38.0",
|
31
35
|
"eslint-config-prettier": "^8.8.0",
|
@@ -34,6 +38,7 @@
|
|
34
38
|
"file-loader": "^6.2.0",
|
35
39
|
"html-loader": "^5.1.0",
|
36
40
|
"html-webpack-plugin": "^5.6.3",
|
41
|
+
"huan-file-tool": "^1.0.5",
|
37
42
|
"jquery": "^3.7.1",
|
38
43
|
"mini-css-extract-plugin": "^2.9.2",
|
39
44
|
"normalize.css": "^8.0.1",
|
@@ -48,10 +53,10 @@
|
|
48
53
|
"webpack-cli": "^6.0.1",
|
49
54
|
"webpack-dev-server": "^5.2.0"
|
50
55
|
},
|
51
|
-
"dependencies": {},
|
52
56
|
"scripts": {
|
53
|
-
"
|
54
|
-
"lint
|
57
|
+
"init": "npx pnpm install",
|
58
|
+
"lint": "eslint --ext .js,.mjs,.cjs --fix .",
|
59
|
+
"lint:debug": "eslint --ext .js,.mjs,.cjs --debug --fix .",
|
55
60
|
"dev": "npx webpack server --config webpack_config_dev.js",
|
56
61
|
"build:dev": "npx webpack --config webpack_config_dev.js",
|
57
62
|
"build:dev:run": "npx pnpm build:dev && npx pnpm dev",
|
@@ -60,6 +65,9 @@
|
|
60
65
|
"build:prod:run": "npx pnpm build:prod && npx pnpm prod",
|
61
66
|
"github": "npx webpack server --config webpack_config_github.js",
|
62
67
|
"build:github": "npx webpack --config webpack_config_github.js && node github-page/cname.js",
|
63
|
-
"
|
68
|
+
"pack": "npx pnpm run init && npx pnpm run lint && npx pnpm pack",
|
69
|
+
"build:github:run": "npx pnpm build:github && npx pnpm github",
|
70
|
+
"login:npmjs": "npx pnpm login --registry=https://registry.npmjs.org",
|
71
|
+
"publish:npmjs": "npx pnpm publish --registry=https://registry.npmjs.org"
|
64
72
|
}
|
65
73
|
}
|
package/src/common.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// 清理状态
|
2
2
|
import 'normalize.css'
|
3
|
-
import jQuery from 'jquery'
|
3
|
+
import jQuery from 'jquery'
|
4
4
|
|
5
5
|
import Logo from './assets/image/logo.png'
|
6
6
|
import WangAn from './assets/image/wangan.png'
|
@@ -20,5 +20,5 @@ window.WangAn = WangAn
|
|
20
20
|
window.SongZihuan = SongZihuan
|
21
21
|
window.LogoBig = LogoBin
|
22
22
|
|
23
|
-
window.jQuery = jQuery
|
24
|
-
window.$ = jQuery
|
23
|
+
window.jQuery = jQuery
|
24
|
+
window.$ = jQuery
|
package/webpack_config_dev.js
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
import path from
|
2
|
-
import HtmlWebpackPlugin from
|
3
|
-
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
4
|
-
import CopyWebpackPlugin from
|
5
|
-
import filetool from '
|
6
|
-
import { fileURLToPath } from 'url'
|
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 'huan-file-tool'
|
6
|
+
import { fileURLToPath } from 'url'
|
7
7
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url)
|
9
|
-
const __dirname = path.dirname(__filename)
|
8
|
+
const __filename = fileURLToPath(import.meta.url)
|
9
|
+
const __dirname = path.dirname(__filename)
|
10
10
|
|
11
11
|
const mode = 'development'
|
12
12
|
const dist_name = 'dist-dev'
|
13
13
|
|
14
14
|
const HTMMLPlugin = []
|
15
15
|
|
16
|
-
const { localPathResult: AllHTMLLocalFile4xx } = filetool.getAllFilePaths(
|
16
|
+
const { localPathResult: AllHTMLLocalFile4xx } = filetool.filewaalk.getAllFilePaths(
|
17
|
+
path.resolve(__dirname, 'src/html/error/4xx')
|
18
|
+
)
|
17
19
|
AllHTMLLocalFile4xx.forEach((filePath) => {
|
18
20
|
if (!filePath.endsWith('.html')) {
|
19
21
|
return
|
@@ -56,7 +58,9 @@ AllHTMLLocalFile4xx.forEach((filePath) => {
|
|
56
58
|
)
|
57
59
|
})
|
58
60
|
|
59
|
-
const { localPathResult: AllHTMLLocalFile5xx } = filetool.getAllFilePaths(
|
61
|
+
const { localPathResult: AllHTMLLocalFile5xx } = filetool.filewaalk.getAllFilePaths(
|
62
|
+
path.resolve(__dirname, 'src/html/error/5xx')
|
63
|
+
)
|
60
64
|
AllHTMLLocalFile5xx.forEach((filePath) => {
|
61
65
|
if (!filePath.endsWith('.html')) {
|
62
66
|
return
|
@@ -86,7 +90,7 @@ AllHTMLLocalFile5xx.forEach((filePath) => {
|
|
86
90
|
)
|
87
91
|
})
|
88
92
|
|
89
|
-
const config =
|
93
|
+
const config = {
|
90
94
|
mode: mode,
|
91
95
|
|
92
96
|
context: __dirname,
|
@@ -126,6 +130,13 @@ const config = {
|
|
126
130
|
|
127
131
|
module: {
|
128
132
|
rules: [
|
133
|
+
{
|
134
|
+
test: /\.(js|mjs|cjs)$/,
|
135
|
+
exclude: /(node_modules|bower_components)/,
|
136
|
+
use: {
|
137
|
+
loader: 'babel-loader'
|
138
|
+
}
|
139
|
+
},
|
129
140
|
{
|
130
141
|
test: /\.(css|scss|sass)$/,
|
131
142
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
|
package/webpack_config_github.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
import path from
|
2
|
-
import HtmlWebpackPlugin from
|
3
|
-
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
4
|
-
import CopyWebpackPlugin from
|
5
|
-
import TerserPlugin from 'terser-webpack-plugin'
|
6
|
-
import filetool from '
|
7
|
-
import { fileURLToPath } from 'url'
|
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 'huan-file-tool'
|
7
|
+
import { fileURLToPath } from 'url'
|
8
8
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url)
|
10
|
-
const __dirname = path.dirname(__filename)
|
9
|
+
const __filename = fileURLToPath(import.meta.url)
|
10
|
+
const __dirname = path.dirname(__filename)
|
11
11
|
|
12
12
|
const mode = 'production'
|
13
13
|
const dist_name = 'docs'
|
@@ -27,7 +27,9 @@ const html_minify = {
|
|
27
27
|
|
28
28
|
const HTMMLPlugin = []
|
29
29
|
|
30
|
-
const { localPathResult: AllHTMLLocalFile4xx } = filetool.getAllFilePaths(
|
30
|
+
const { localPathResult: AllHTMLLocalFile4xx } = filetool.filewaalk.getAllFilePaths(
|
31
|
+
path.resolve(__dirname, 'src/html/error/4xx')
|
32
|
+
)
|
31
33
|
AllHTMLLocalFile4xx.forEach((filePath) => {
|
32
34
|
if (!filePath.endsWith('.html')) {
|
33
35
|
return
|
@@ -70,7 +72,9 @@ AllHTMLLocalFile4xx.forEach((filePath) => {
|
|
70
72
|
)
|
71
73
|
})
|
72
74
|
|
73
|
-
const { localPathResult: AllHTMLLocalFile5xx } = filetool.getAllFilePaths(
|
75
|
+
const { localPathResult: AllHTMLLocalFile5xx } = filetool.filewaalk.getAllFilePaths(
|
76
|
+
path.resolve(__dirname, 'src/html/error/5xx')
|
77
|
+
)
|
74
78
|
AllHTMLLocalFile5xx.forEach((filePath) => {
|
75
79
|
if (!filePath.endsWith('.html')) {
|
76
80
|
return
|
@@ -154,6 +158,13 @@ const config = {
|
|
154
158
|
|
155
159
|
module: {
|
156
160
|
rules: [
|
161
|
+
{
|
162
|
+
test: /\.(js|mjs|cjs)$/,
|
163
|
+
exclude: /(node_modules|bower_components)/,
|
164
|
+
use: {
|
165
|
+
loader: 'babel-loader'
|
166
|
+
}
|
167
|
+
},
|
157
168
|
{
|
158
169
|
test: /\.(css|scss|sass)$/,
|
159
170
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
|
@@ -203,7 +214,7 @@ const config = {
|
|
203
214
|
{
|
204
215
|
test: /\.html$/i,
|
205
216
|
loader: 'html-loader'
|
206
|
-
}
|
217
|
+
}
|
207
218
|
]
|
208
219
|
},
|
209
220
|
|
@@ -290,4 +301,4 @@ const config = {
|
|
290
301
|
}
|
291
302
|
}
|
292
303
|
|
293
|
-
export default config
|
304
|
+
export default config
|
package/webpack_config_prod.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import path from
|
2
|
-
import HtmlWebpackPlugin from
|
3
|
-
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
4
|
-
import CopyWebpackPlugin from
|
5
|
-
import filetool from '
|
6
|
-
import { fileURLToPath } from 'url'
|
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 'huan-file-tool'
|
6
|
+
import { fileURLToPath } from 'url'
|
7
7
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url)
|
9
|
-
const __dirname = path.dirname(__filename)
|
8
|
+
const __filename = fileURLToPath(import.meta.url)
|
9
|
+
const __dirname = path.dirname(__filename)
|
10
10
|
|
11
11
|
const mode = 'production'
|
12
12
|
const dist_name = 'dist-prod'
|
@@ -26,7 +26,9 @@ const html_minify = {
|
|
26
26
|
|
27
27
|
const HTMMLPlugin = []
|
28
28
|
|
29
|
-
const { localPathResult: AllHTMLLocalFile4xx } = filetool.getAllFilePaths(
|
29
|
+
const { localPathResult: AllHTMLLocalFile4xx } = filetool.filewaalk.getAllFilePaths(
|
30
|
+
path.resolve(__dirname, 'src/html/error/4xx')
|
31
|
+
)
|
30
32
|
AllHTMLLocalFile4xx.forEach((filePath) => {
|
31
33
|
if (!filePath.endsWith('.html')) {
|
32
34
|
return
|
@@ -69,7 +71,9 @@ AllHTMLLocalFile4xx.forEach((filePath) => {
|
|
69
71
|
)
|
70
72
|
})
|
71
73
|
|
72
|
-
const { localPathResult: AllHTMLLocalFile5xx } = filetool.getAllFilePaths(
|
74
|
+
const { localPathResult: AllHTMLLocalFile5xx } = filetool.filewaalk.getAllFilePaths(
|
75
|
+
path.resolve(__dirname, 'src/html/error/5xx')
|
76
|
+
)
|
73
77
|
AllHTMLLocalFile5xx.forEach((filePath) => {
|
74
78
|
if (!filePath.endsWith('.html')) {
|
75
79
|
return
|
@@ -139,6 +143,13 @@ const config = {
|
|
139
143
|
|
140
144
|
module: {
|
141
145
|
rules: [
|
146
|
+
{
|
147
|
+
test: /\.(js|mjs|cjs)$/,
|
148
|
+
exclude: /(node_modules|bower_components)/,
|
149
|
+
use: {
|
150
|
+
loader: 'babel-loader'
|
151
|
+
}
|
152
|
+
},
|
142
153
|
{
|
143
154
|
test: /\.(css|scss|sass)$/,
|
144
155
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
|
@@ -275,4 +286,4 @@ const config = {
|
|
275
286
|
}
|
276
287
|
}
|
277
288
|
|
278
|
-
export default config
|
289
|
+
export default config
|
package/src/utils/file.js
DELETED
@@ -1,45 +0,0 @@
|
|
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
|
-
}
|