huan-simple-html 1.1.0 → 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/package.json +4 -3
- package/webpack_config_dev.js +7 -3
- package/webpack_config_github.js +7 -3
- package/webpack_config_prod.js +7 -3
- package/src/utils/file.js +0 -45
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "huan-simple-html",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.1",
|
4
4
|
"description": "一个简单的HTML项目,通过Webpack进行打包。请尽量使用pnpm处理此包。更多细节请查看\"README.md\"",
|
5
5
|
"keywords": [
|
6
6
|
"html",
|
@@ -38,6 +38,7 @@
|
|
38
38
|
"file-loader": "^6.2.0",
|
39
39
|
"html-loader": "^5.1.0",
|
40
40
|
"html-webpack-plugin": "^5.6.3",
|
41
|
+
"huan-file-tool": "^1.0.5",
|
41
42
|
"jquery": "^3.7.1",
|
42
43
|
"mini-css-extract-plugin": "^2.9.2",
|
43
44
|
"normalize.css": "^8.0.1",
|
@@ -54,8 +55,8 @@
|
|
54
55
|
},
|
55
56
|
"scripts": {
|
56
57
|
"init": "npx pnpm install",
|
57
|
-
"lint": "eslint --ext .js,.mjs,.cjs
|
58
|
-
"lint:debug": "eslint --ext .js,.mjs,.cjs
|
58
|
+
"lint": "eslint --ext .js,.mjs,.cjs --fix .",
|
59
|
+
"lint:debug": "eslint --ext .js,.mjs,.cjs --debug --fix .",
|
59
60
|
"dev": "npx webpack server --config webpack_config_dev.js",
|
60
61
|
"build:dev": "npx webpack --config webpack_config_dev.js",
|
61
62
|
"build:dev:run": "npx pnpm build:dev && npx pnpm dev",
|
package/webpack_config_dev.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'path'
|
|
2
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
4
4
|
import CopyWebpackPlugin from 'copy-webpack-plugin'
|
5
|
-
import filetool from '
|
5
|
+
import filetool from 'huan-file-tool'
|
6
6
|
import { fileURLToPath } from 'url'
|
7
7
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url)
|
@@ -13,7 +13,9 @@ 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
|
package/webpack_config_github.js
CHANGED
@@ -3,7 +3,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
4
4
|
import CopyWebpackPlugin from 'copy-webpack-plugin'
|
5
5
|
import TerserPlugin from 'terser-webpack-plugin'
|
6
|
-
import filetool from '
|
6
|
+
import filetool from 'huan-file-tool'
|
7
7
|
import { fileURLToPath } from 'url'
|
8
8
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url)
|
@@ -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
|
package/webpack_config_prod.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'path'
|
|
2
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
4
4
|
import CopyWebpackPlugin from 'copy-webpack-plugin'
|
5
|
-
import filetool from '
|
5
|
+
import filetool from 'huan-file-tool'
|
6
6
|
import { fileURLToPath } from 'url'
|
7
7
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url)
|
@@ -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
|
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
|
-
}
|