@tuya-sat/micro-script 2.3.2 → 2.3.5
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/dist/config/webpack.common.js +9 -16
- package/dist/scripts/build.js +12 -7
- package/package.json +4 -4
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
15
16
|
//@ts-ignore
|
|
16
17
|
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
17
18
|
//@ts-ignore
|
|
@@ -23,6 +24,7 @@ const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
|
|
|
23
24
|
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
24
25
|
const paths_1 = __importDefault(require("./paths"));
|
|
25
26
|
const theme_1 = require("../utils/theme");
|
|
27
|
+
const DYNAMIC_CHUNK_PREFIX = "micro_app_lazy";
|
|
26
28
|
const toArray = (value) => {
|
|
27
29
|
return Array.isArray(value) ? value : [value];
|
|
28
30
|
};
|
|
@@ -61,7 +63,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
61
63
|
? "static/js/[name].[contenthash:8].js"
|
|
62
64
|
: "static/js/[name].bundle.js",
|
|
63
65
|
chunkFilename: isBuild
|
|
64
|
-
?
|
|
66
|
+
? `static/js/${DYNAMIC_CHUNK_PREFIX}-[name].[contenthash:8].chunk.js`
|
|
65
67
|
: "static/js/[name].chunk.js",
|
|
66
68
|
path: paths_1.default.dist,
|
|
67
69
|
clean: true,
|
|
@@ -115,28 +117,18 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
115
117
|
].filter(Boolean),
|
|
116
118
|
},
|
|
117
119
|
optimization: {
|
|
118
|
-
runtimeChunk: "single",
|
|
119
120
|
splitChunks: {
|
|
120
|
-
cacheGroups: Object.assign(
|
|
121
|
+
cacheGroups: Object.assign({}, (enableThemeCompile
|
|
121
122
|
? {
|
|
122
123
|
vendorCss: {
|
|
123
124
|
test: /([\\/]node_modules[\\/][\s\S]+(\.less|\.css)$)|([\\/]src[\\/]styles[\\/]global\.less)/,
|
|
124
125
|
name: "light",
|
|
125
126
|
chunks: "all",
|
|
127
|
+
minSize: 0,
|
|
126
128
|
priority: 2,
|
|
127
129
|
},
|
|
128
130
|
}
|
|
129
|
-
: {})),
|
|
130
|
-
test: /[\\/]node_modules[\\/]/,
|
|
131
|
-
name: "vendors-others",
|
|
132
|
-
chunks: "all",
|
|
133
|
-
priority: 0,
|
|
134
|
-
}, react: {
|
|
135
|
-
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
|
|
136
|
-
name: "react-related",
|
|
137
|
-
chunks: "all",
|
|
138
|
-
priority: 1,
|
|
139
|
-
} }),
|
|
131
|
+
: {})),
|
|
140
132
|
},
|
|
141
133
|
minimizer: ["...", new css_minimizer_webpack_plugin_1.default()],
|
|
142
134
|
},
|
|
@@ -149,7 +141,8 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
149
141
|
patterns: [
|
|
150
142
|
{
|
|
151
143
|
from: paths_1.default.publicDir,
|
|
152
|
-
|
|
144
|
+
// 使用path.resolve纠正resourcePath,因为这个resourcePath值在windows平台显示的是POSIX值;
|
|
145
|
+
filter: (resourcePath) => __awaiter(this, void 0, void 0, function* () { return path_1.default.resolve(resourcePath) !== paths_1.default.spaHtml; }),
|
|
153
146
|
noErrorOnMissing: true,
|
|
154
147
|
},
|
|
155
148
|
],
|
|
@@ -157,7 +150,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
157
150
|
isBuild &&
|
|
158
151
|
new mini_css_extract_plugin_1.default({
|
|
159
152
|
filename: "static/css/[name].[contenthash:8].css",
|
|
160
|
-
chunkFilename:
|
|
153
|
+
chunkFilename: `static/css/${DYNAMIC_CHUNK_PREFIX}-[name].[contenthash:8].chunk.css`,
|
|
161
154
|
}),
|
|
162
155
|
isBuild && enableThemeCompile && new micro_dev_loader_1.ThemePlugin(),
|
|
163
156
|
].filter((value) => Boolean(value)),
|
package/dist/scripts/build.js
CHANGED
|
@@ -30,11 +30,16 @@ const config = (0, webpack_config_1.default)();
|
|
|
30
30
|
console.log(warnings.map((item) => item.message).join("\n"));
|
|
31
31
|
}
|
|
32
32
|
console.log(chalk_1.default.yellow(`当前打包工具:webpack@${version}`));
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
if (assets) {
|
|
34
|
+
console.log(chalk_1.default.blue("资源清单:"));
|
|
35
|
+
const assetsInfo = assets.map(({ size, name }) => {
|
|
36
|
+
return ` ${name} ${chalk_1.default.white(size > 1024 ? `~${Math.floor(size / 1024)}KB` : `${size}B`)}`;
|
|
37
|
+
});
|
|
38
|
+
assetsInfo.map((item) => {
|
|
39
|
+
console.log(chalk_1.default.blue(item));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log(chalk_1.default.blue("无资源清单"));
|
|
44
|
+
}
|
|
40
45
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@babel/preset-react": "7.16.7",
|
|
21
21
|
"@babel/preset-typescript": "7.16.7",
|
|
22
22
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
23
|
-
"@tuya-sat/micro-dev-loader": "2.3.
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.3.
|
|
25
|
-
"@tuya-sat/micro-utils": "2.3.
|
|
23
|
+
"@tuya-sat/micro-dev-loader": "2.3.5",
|
|
24
|
+
"@tuya-sat/micro-dev-proxy": "2.3.5",
|
|
25
|
+
"@tuya-sat/micro-utils": "2.3.5",
|
|
26
26
|
"babel-loader": "8.2.4",
|
|
27
27
|
"babel-plugin-import": "1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|