@tmsfe/tmskit 0.0.7 → 0.0.9-beta.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/README.md +27 -27
- package/dist/index.cjs.js +1284 -983
- package/main.js +3 -3
- package/package.json +73 -75
- package/src/{gulp → compile}/build.js +5 -5
- package/src/{gulp → compile}/compile.js +90 -81
- package/src/{gulp → compile}/dev.js +129 -102
- package/src/{gulp → compile}/plugins/less.js +116 -116
- package/src/{gulp → compile}/plugins/mpCommonDep.js +131 -131
- package/src/{gulp → compile}/plugins/mpJsonDep.js +112 -108
- package/src/{gulp → compile}/plugins/mpWxmlDep.js +194 -194
- package/src/{gulp → compile}/plugins/postcss-font-base64.js +72 -72
- package/src/{gulp → compile}/plugins/replaceEnv.js +29 -29
- package/src/{gulp → compile}/plugins/utils/pluginError.js +25 -25
- package/src/config/constant.js +69 -71
- package/src/config/defaultTmsConfig.js +16 -16
- package/src/{utils → core}/buildAppJson.js +166 -221
- package/src/{utils → core}/checkDependencies.js +77 -77
- package/src/core/cloneModules.js +203 -0
- package/src/{utils → core}/handleError.js +18 -16
- package/src/core/isInIt.js +69 -0
- package/src/{utils/mpCiUtils.js → core/mpCi.js} +73 -73
- package/src/core/npm.js +218 -0
- package/src/core/symbolicLink.js +24 -0
- package/src/{utils/tkitUtils.js → core/tmsMpconfig.js} +234 -158
- package/src/entry.js +62 -60
- package/src/index.js +63 -62
- package/src/init.js +33 -33
- package/src/scripts/create/ask.js +63 -63
- package/src/scripts/create/generator.js +25 -25
- package/src/scripts/create/ignoreFiles.js +7 -7
- package/src/scripts/create/index.js +72 -72
- package/src/scripts/create/render.js +19 -19
- package/src/scripts/run/build/index.js +16 -17
- package/src/scripts/run/dev/index.js +42 -84
- package/src/scripts/run/index.js +97 -68
- package/src/scripts/run/init/index.js +95 -87
- package/src/scripts/run/install/index.js +31 -29
- package/src/utils/findCssImport.js +30 -30
- package/src/utils/global.js +22 -36
- package/src/utils/io.js +107 -106
- package/src/utils/log.js +47 -44
- package/src/utils/widgets.js +178 -167
- package/src/utils/cliUtils.js +0 -35
- package/src/utils/cloneModules.js +0 -116
- package/src/utils/npmUtils.js +0 -166
package/main.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require('
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('dist/index.cjs.js'); // eslint-disable-line
|
package/package.json
CHANGED
|
@@ -1,75 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tmsfe/tmskit",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "tmskit",
|
|
5
|
-
"main": "
|
|
6
|
-
"bin": {
|
|
7
|
-
"tmskit": "main.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"src",
|
|
11
|
-
"dist",
|
|
12
|
-
"main.js",
|
|
13
|
-
"package.json"
|
|
14
|
-
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"dev": "rollup -wc --environment TARGET:tmskit",
|
|
17
|
-
"build": "rollup -c --environment TARGET:tmskit"
|
|
18
|
-
},
|
|
19
|
-
"author": "tms·web",
|
|
20
|
-
"license": "ISC",
|
|
21
|
-
"buildOptions": {
|
|
22
|
-
"formats": [
|
|
23
|
-
"cjs"
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@rollup/plugin-babel": "^5.0.2",
|
|
28
|
-
"@rollup/plugin-commonjs": "^19.0.0",
|
|
29
|
-
"@rollup/plugin-dynamic-import-vars": "^1.1.1",
|
|
30
|
-
"@rollup/plugin-json": "^4.0.3",
|
|
31
|
-
"rollup": "^2.6.1",
|
|
32
|
-
"rollup-plugin-node-resolve": "^5.2.0",
|
|
33
|
-
"rollup-plugin-replace": "^2.2.0",
|
|
34
|
-
"rollup-plugin-terser": "^6.1.0",
|
|
35
|
-
"rollup-plugin-typescript2": "0.27.0"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"async": "^3.2.2",
|
|
39
|
-
"chalk": "^4.1.0",
|
|
40
|
-
"commander": "^8.3.0",
|
|
41
|
-
"copy-webpack-plugin": "^9.1.0",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"gulp": "^
|
|
47
|
-
"gulp-
|
|
48
|
-
"gulp-
|
|
49
|
-
"gulp-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tmsfe/tmskit",
|
|
3
|
+
"version": "0.0.9-beta.1",
|
|
4
|
+
"description": "tmskit",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tmskit": "main.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"dist",
|
|
12
|
+
"main.js",
|
|
13
|
+
"package.json"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "rollup -wc --environment TARGET:tmskit",
|
|
17
|
+
"build": "rollup -c --environment TARGET:tmskit"
|
|
18
|
+
},
|
|
19
|
+
"author": "tms·web",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"buildOptions": {
|
|
22
|
+
"formats": [
|
|
23
|
+
"cjs"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rollup/plugin-babel": "^5.0.2",
|
|
28
|
+
"@rollup/plugin-commonjs": "^19.0.0",
|
|
29
|
+
"@rollup/plugin-dynamic-import-vars": "^1.1.1",
|
|
30
|
+
"@rollup/plugin-json": "^4.0.3",
|
|
31
|
+
"rollup": "^2.6.1",
|
|
32
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
33
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
34
|
+
"rollup-plugin-terser": "^6.1.0",
|
|
35
|
+
"rollup-plugin-typescript2": "0.27.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"async": "^3.2.2",
|
|
39
|
+
"chalk": "^4.1.0",
|
|
40
|
+
"commander": "^8.3.0",
|
|
41
|
+
"copy-webpack-plugin": "^9.1.0",
|
|
42
|
+
"ejs": "^3.1.5",
|
|
43
|
+
"fs-extra": "^10.0.1",
|
|
44
|
+
"glob-ignore": "^1.0.2",
|
|
45
|
+
"gulp": "^4.0.2",
|
|
46
|
+
"gulp-cache": "^1.1.3",
|
|
47
|
+
"gulp-postcss": "^9.0.1",
|
|
48
|
+
"gulp-px-to-rpx": "^1.0.7",
|
|
49
|
+
"gulp-watch": "^5.0.1",
|
|
50
|
+
"htmlparser2": "^7.2.0",
|
|
51
|
+
"inquirer": "^7.3.3",
|
|
52
|
+
"leven": "3.1.0",
|
|
53
|
+
"lodash": "^4.17.21",
|
|
54
|
+
"metalsmith": "^2.3.0",
|
|
55
|
+
"miniprogram-ci": "1.4.13",
|
|
56
|
+
"object-assign": "^4.0.1",
|
|
57
|
+
"ora": "^5.1.0",
|
|
58
|
+
"plugin-error": "^1.0.0",
|
|
59
|
+
"postcss": "^8.4.6",
|
|
60
|
+
"precinct": "^8.3.1",
|
|
61
|
+
"replace-ext": "^2.0.0",
|
|
62
|
+
"shelljs": "^0.8.4",
|
|
63
|
+
"strip-comments": "^2.0.1",
|
|
64
|
+
"through2": "^4.0.2",
|
|
65
|
+
"vinyl-sourcemaps-apply": "^0.2.0"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": "^12.17.0 || >= 14.13.1"
|
|
69
|
+
},
|
|
70
|
+
"jest": {
|
|
71
|
+
"testEnvironment": "jest-environment-node"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const dev = require('./dev');
|
|
2
|
-
|
|
3
|
-
module.exports = async (tmsConfig, newModules) => {
|
|
4
|
-
dev(tmsConfig, newModules, false);
|
|
5
|
-
};
|
|
1
|
+
const dev = require('./dev');
|
|
2
|
+
|
|
3
|
+
module.exports = async (tmsConfig, newModules) => {
|
|
4
|
+
dev(tmsConfig, newModules, false);
|
|
5
|
+
};
|
|
@@ -1,81 +1,90 @@
|
|
|
1
|
-
const { src, dest, lastRun } = require('gulp');
|
|
2
|
-
const px2rpx = require('gulp-px-to-rpx');
|
|
3
|
-
const watch = require('gulp-watch');
|
|
4
|
-
// const cache = require('gulp-cache');
|
|
5
|
-
// const image = require('gulp-image');
|
|
6
|
-
const replaceEnv = require('./plugins/replaceEnv');
|
|
7
|
-
const { mpCommonDep } = require('./plugins/mpCommonDep');
|
|
8
|
-
const { mpJsonDep } = require('./plugins/mpJsonDep');
|
|
9
|
-
const { mpWxmlDep } = require('./plugins/mpWxmlDep');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.pipe(
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
.pipe(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.pipe(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
const { src, dest, lastRun } = require('gulp');
|
|
2
|
+
const px2rpx = require('gulp-px-to-rpx');
|
|
3
|
+
const watch = require('gulp-watch');
|
|
4
|
+
// const cache = require('gulp-cache');
|
|
5
|
+
// const image = require('gulp-image');
|
|
6
|
+
// const replaceEnv = require('./plugins/replaceEnv');
|
|
7
|
+
const { mpCommonDep } = require('./plugins/mpCommonDep');
|
|
8
|
+
const { mpJsonDep } = require('./plugins/mpJsonDep');
|
|
9
|
+
const { mpWxmlDep } = require('./plugins/mpWxmlDep');
|
|
10
|
+
// const postcss = require('gulp-postcss');
|
|
11
|
+
// const base64 = require('./plugins/postcss-font-base64');
|
|
12
|
+
const { fail } = require('../utils/log');
|
|
13
|
+
|
|
14
|
+
const since = task => file => (lastRun(task) > file.stat.ctime ? lastRun(task) : 0);
|
|
15
|
+
module.exports = function (
|
|
16
|
+
tmsConfig,
|
|
17
|
+
{
|
|
18
|
+
glob,
|
|
19
|
+
destPath,
|
|
20
|
+
srcOption,
|
|
21
|
+
module,
|
|
22
|
+
watchOption = { events: ['change', 'add', 'unlink'] },
|
|
23
|
+
isWatch,
|
|
24
|
+
},
|
|
25
|
+
) {
|
|
26
|
+
Object.keys(glob).forEach((globKey) => {
|
|
27
|
+
const globValue = glob[globKey];
|
|
28
|
+
const task = () => src(globValue, { ...srcOption, since: since(task) });
|
|
29
|
+
let srcPipe = task();
|
|
30
|
+
|
|
31
|
+
if (isWatch) {
|
|
32
|
+
srcPipe = srcPipe.pipe(watch(globValue, watchOption));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
switch (globKey) {
|
|
36
|
+
case 'js':
|
|
37
|
+
srcPipe
|
|
38
|
+
// .pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData))
|
|
39
|
+
.pipe(mpCommonDep(tmsConfig, module, ['.js', '.ts', '.wxs', '.json'], isWatch))
|
|
40
|
+
.pipe(dest(destPath))
|
|
41
|
+
.on('error', (err) => {
|
|
42
|
+
fail(`js编译报错${err}`);
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
case 'wxss':
|
|
46
|
+
srcPipe
|
|
47
|
+
.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isWatch))
|
|
48
|
+
.on('error', (err) => {
|
|
49
|
+
fail(`mpCommonDep编译报错${err}`);
|
|
50
|
+
})
|
|
51
|
+
// .pipe(postcss([base64()]))
|
|
52
|
+
// .on('error', (err) => {
|
|
53
|
+
// fail(`postcss编译报错${err}`);
|
|
54
|
+
// })
|
|
55
|
+
.pipe(px2rpx({
|
|
56
|
+
designWidth: 375, // 设计稿宽度,默认为750
|
|
57
|
+
precision: 2, // 小数最大精度,默认为6
|
|
58
|
+
}))
|
|
59
|
+
.pipe(dest(destPath));
|
|
60
|
+
break;
|
|
61
|
+
case 'json':
|
|
62
|
+
srcPipe
|
|
63
|
+
.pipe(mpJsonDep(tmsConfig, module, ['.json'], ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isWatch))
|
|
64
|
+
.on('error', (err) => {
|
|
65
|
+
fail(`mpJsonDep编译报错${err}`);
|
|
66
|
+
})
|
|
67
|
+
.pipe(dest(destPath));
|
|
68
|
+
break;
|
|
69
|
+
case 'wxml':
|
|
70
|
+
srcPipe
|
|
71
|
+
.pipe(mpWxmlDep(tmsConfig, module, isWatch))
|
|
72
|
+
.pipe(dest(destPath));
|
|
73
|
+
break;
|
|
74
|
+
case 'image':
|
|
75
|
+
srcPipe
|
|
76
|
+
// .pipe(cache(image()))
|
|
77
|
+
// .on('error', (err) => {
|
|
78
|
+
// fail(`image编译报错${err}`);
|
|
79
|
+
// })
|
|
80
|
+
.pipe(dest(destPath));
|
|
81
|
+
break;
|
|
82
|
+
case 'other':
|
|
83
|
+
srcPipe
|
|
84
|
+
.pipe(dest(destPath));
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
@@ -1,102 +1,129 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
module
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const watch = require('gulp-watch');
|
|
4
|
+
const { resolve } = require('../utils/widgets');
|
|
5
|
+
const { buildOutputAppJson } = require('../core/buildAppJson');
|
|
6
|
+
const { DEFAULT_COPY_CONFIG } = require('../config/constant');
|
|
7
|
+
const compile = require('./compile');
|
|
8
|
+
|
|
9
|
+
function excludeGlob(glob) {
|
|
10
|
+
const otherArr = new Set();
|
|
11
|
+
otherArr.add('!**/*.{ttf,otf,woff,eot}');
|
|
12
|
+
Object.keys(glob).forEach((globKey) => {
|
|
13
|
+
if (typeof glob[globKey] === 'string') {
|
|
14
|
+
const data = glob[globKey].startsWith('!') ? glob[globKey] : `!${glob[globKey]}`;
|
|
15
|
+
otherArr.add(data);
|
|
16
|
+
} if (Array.isArray(glob[globKey])) {
|
|
17
|
+
glob[globKey].forEach((value) => {
|
|
18
|
+
if (typeof value === 'string') {
|
|
19
|
+
const data = value.startsWith('!') ? value : `!${value}`;
|
|
20
|
+
otherArr.add(data);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return Array.from(otherArr);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function adaptPath(pathDir) {
|
|
29
|
+
let newPath = pathDir;
|
|
30
|
+
newPath = newPath.startsWith('/') ? newPath : resolve(newPath);
|
|
31
|
+
newPath = newPath.endsWith('/') ? newPath.slice(0, newPath.length - 1) : newPath;
|
|
32
|
+
return newPath;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = async (tmsConfig, newModules, isWatch = true) => {
|
|
36
|
+
// 监听app.json
|
|
37
|
+
if (isWatch) {
|
|
38
|
+
watch(resolve('app.json'), { ignoreInitial: false, events: ['add', 'change'] }, () => {
|
|
39
|
+
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 监听根目录的文件
|
|
46
|
+
compile(tmsConfig, {
|
|
47
|
+
glob: {
|
|
48
|
+
json: DEFAULT_COPY_CONFIG.map(item => resolve(item)),
|
|
49
|
+
// wxss: ['app.less', 'app.wxss'].map(item => resolve(item)),
|
|
50
|
+
// js: ['app.js', 'app.ts'].map(item => resolve(item)),
|
|
51
|
+
},
|
|
52
|
+
module: { from: '', to: '' },
|
|
53
|
+
destPath: resolve(tmsConfig.outputDir),
|
|
54
|
+
srcOption: { allowEmpty: true },
|
|
55
|
+
isWatch,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// 监听模块的文件
|
|
59
|
+
for (let module of newModules) {
|
|
60
|
+
// 处理默认参数
|
|
61
|
+
module = {
|
|
62
|
+
...{ exclude: [] },
|
|
63
|
+
...module,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
if (isWatch) {
|
|
67
|
+
// 监听模块配置文件
|
|
68
|
+
watch(`${resolve(module.path)}/**/module.config.json`, { events: ['change'] }, () => {
|
|
69
|
+
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const excludes = module.exclude.map(key => `!${resolve(key)}`);
|
|
74
|
+
const modulePath = adaptPath(module.path);
|
|
75
|
+
const glob = {
|
|
76
|
+
js: [`${modulePath}/**/*.{js,ts,wxs}`, ...excludes],
|
|
77
|
+
json: [`${modulePath}/**/*.json`, ...excludes],
|
|
78
|
+
wxss: [`${modulePath}/**/*.{less,wxss}`, ...excludes],
|
|
79
|
+
wxml: [`${modulePath}/**/*.wxml`, ...excludes],
|
|
80
|
+
image: [`${modulePath}/**/*.{png,jpg,jpeg,gif,svg}`, ...excludes],
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
compile(tmsConfig, {
|
|
84
|
+
glob: {
|
|
85
|
+
...glob,
|
|
86
|
+
other: [`${modulePath}/**/*`, ...excludeGlob(glob)],
|
|
87
|
+
},
|
|
88
|
+
destPath: resolve(tmsConfig.outputDir, module.root),
|
|
89
|
+
module: { from: module.path, to: module.root },
|
|
90
|
+
srcOption: { allowEmpty: true },
|
|
91
|
+
isWatch,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 静态资源目录-拷贝
|
|
96
|
+
if (tmsConfig?.static && tmsConfig?.static.length > 0) {
|
|
97
|
+
for (const item of tmsConfig.static) {
|
|
98
|
+
item.from = adaptPath(item.from);
|
|
99
|
+
item.to = adaptPath(item.to);
|
|
100
|
+
|
|
101
|
+
let glob = {};
|
|
102
|
+
const ext = path.extname(item.from).slice(1);
|
|
103
|
+
if (ext) {
|
|
104
|
+
glob[ext] = [item.from];
|
|
105
|
+
} else {
|
|
106
|
+
glob = {
|
|
107
|
+
js: [`${item.from}/**/*.{js,ts,wxs}`],
|
|
108
|
+
json: [`${item.from}/**/*.json`],
|
|
109
|
+
wxss: [`${item.from}/**/*.{less,wxss}`],
|
|
110
|
+
wxml: [`${item.from}/**/*.wxml`],
|
|
111
|
+
image: [`${item.from}/**/*.{png,jpg,jpeg,gif,svg}`],
|
|
112
|
+
};
|
|
113
|
+
glob.other = [`${item.from}/**/*`, ...excludeGlob(glob)];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const from = fs.lstatSync(item.from).isFile() ? path.dirname(item.from) : item.from;
|
|
117
|
+
compile(tmsConfig, {
|
|
118
|
+
glob,
|
|
119
|
+
destPath: item.to,
|
|
120
|
+
module: {
|
|
121
|
+
from,
|
|
122
|
+
to: item.to,
|
|
123
|
+
},
|
|
124
|
+
srcOption: { allowEmpty: true },
|
|
125
|
+
isWatch,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|