@tuya-sat/micro-script 2.2.16 → 2.2.18
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.
|
@@ -21,6 +21,7 @@ const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
|
21
21
|
const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
|
|
22
22
|
const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
|
|
23
23
|
const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
|
|
24
|
+
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
24
25
|
const paths_1 = __importDefault(require("./paths"));
|
|
25
26
|
const isExistPostcssFile = () => {
|
|
26
27
|
return fs_extra_1.default.existsSync("postcss.config.js");
|
|
@@ -29,16 +30,20 @@ const toArray = (value) => {
|
|
|
29
30
|
return Array.isArray(value) ? value : [value];
|
|
30
31
|
};
|
|
31
32
|
const validateMicroTheme = () => {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
console.error(`请设置正确的MICRO_THEME
|
|
33
|
+
const microTheme = process.env.MICRO_THEME;
|
|
34
|
+
if (microTheme && ![index_1.DARK_THEME, index_1.LIGHT_THEME].includes(microTheme)) {
|
|
35
|
+
console.error(`请设置正确的MICRO_THEME环境变量,当前值为${microTheme},请修改为${index_1.LIGHT_THEME}或${index_1.DARK_THEME}`);
|
|
35
36
|
return process.exit(1);
|
|
36
37
|
}
|
|
37
|
-
return
|
|
38
|
+
return microTheme;
|
|
38
39
|
};
|
|
39
40
|
function getCommonConfig({ isDev, isBuild, }) {
|
|
40
41
|
const { name: packageName } = require(paths_1.default.appPkg);
|
|
41
|
-
const
|
|
42
|
+
const { annotations } = (0, micro_utils_1.parseManifest)();
|
|
43
|
+
const devMicroTheme = validateMicroTheme();
|
|
44
|
+
const enableThemeCompile = isDev
|
|
45
|
+
? !!devMicroTheme
|
|
46
|
+
: annotations["sdf.feat:theme"];
|
|
42
47
|
//获取style处理的loader
|
|
43
48
|
const getStyleLoaders = (extraLoader = []) => {
|
|
44
49
|
extraLoader = toArray(extraLoader);
|
|
@@ -103,12 +108,16 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
103
108
|
{
|
|
104
109
|
loader: require.resolve("less-loader"),
|
|
105
110
|
options: {
|
|
106
|
-
lessOptions: Object.assign(Object.assign({}, (
|
|
107
|
-
?
|
|
108
|
-
|
|
111
|
+
lessOptions: Object.assign(Object.assign({}, (isDev
|
|
112
|
+
? enableThemeCompile
|
|
113
|
+
? (0, index_1.getLessOptions)(devMicroTheme)
|
|
114
|
+
: {}
|
|
115
|
+
: annotations["sdf.feat:theme"]
|
|
116
|
+
? (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
|
|
117
|
+
: {})), { javascriptEnabled: true }),
|
|
109
118
|
},
|
|
110
119
|
},
|
|
111
|
-
|
|
120
|
+
enableThemeCompile &&
|
|
112
121
|
require("@tuya-sat/micro-dev-loader").changeAntdGlobalImport,
|
|
113
122
|
].filter(Boolean)),
|
|
114
123
|
},
|
|
@@ -133,7 +142,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
133
142
|
optimization: {
|
|
134
143
|
runtimeChunk: "single",
|
|
135
144
|
splitChunks: {
|
|
136
|
-
cacheGroups: Object.assign(Object.assign({}, (
|
|
145
|
+
cacheGroups: Object.assign(Object.assign({}, (enableThemeCompile
|
|
137
146
|
? {
|
|
138
147
|
vendorCss: {
|
|
139
148
|
test: /([\\/]node_modules[\\/][\s\S]+(.less|.css)$)|([\\/]src[\\/]styles[\\/]global.less)/,
|
|
@@ -175,7 +184,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
175
184
|
filename: "static/css/[name].[contenthash:8].css",
|
|
176
185
|
chunkFilename: "static/css/[name].[contenthash:8].chunk.css",
|
|
177
186
|
}),
|
|
178
|
-
isBuild &&
|
|
187
|
+
isBuild && enableThemeCompile && new micro_dev_loader_1.ThemePlugin(),
|
|
179
188
|
].filter((value) => Boolean(value)),
|
|
180
189
|
};
|
|
181
190
|
}
|
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
6
|
const webpack_merge_1 = require("webpack-merge");
|
|
8
7
|
const paths_1 = __importDefault(require("./paths"));
|
|
9
8
|
const framework_1 = __importDefault(require("../framework"));
|
|
10
9
|
const webpack_common_1 = __importDefault(require("./webpack.common"));
|
|
10
|
+
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
11
11
|
exports.default = () => {
|
|
12
12
|
const isBuild = process.env.NODE_ENV === "production";
|
|
13
13
|
const isDev = process.env.NODE_ENV === "development";
|
|
14
|
-
const { annotations: { ["sdf.cli:microFramework"]: currentFramework }, } =
|
|
14
|
+
const { annotations: { ["sdf.cli:microFramework"]: currentFramework }, } = (0, micro_utils_1.parseManifest)();
|
|
15
15
|
//框架的webpack配置
|
|
16
16
|
const frameworkConfig = (0, framework_1.default)({
|
|
17
17
|
currentFramework,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Configuration } from "webpack";
|
|
2
2
|
import { BaseParams } from "../config/webpack.config";
|
|
3
|
+
import { MICRO_FRAMEWORKS_TYPE } from "@tuya-sat/micro-utils";
|
|
3
4
|
export interface Params extends BaseParams {
|
|
4
5
|
currentFramework: MICRO_FRAMEWORKS_TYPE;
|
|
5
6
|
}
|
|
6
7
|
export interface ParamsWithTs extends Params {
|
|
7
8
|
isTs: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare type MICRO_FRAMEWORKS_TYPE = "REACT_TS" | "REACT_JS" | "VUE_TS" | "VUE_JS";
|
|
10
10
|
export declare type FrameworkFunction = (arg0: Params) => Configuration;
|
|
11
11
|
declare const _default: ({ currentFramework, isDev, isBuild }: Params) => Configuration;
|
|
12
12
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.18",
|
|
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.2.
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.2.
|
|
25
|
-
"@tuya-sat/micro-utils": "2.2.
|
|
23
|
+
"@tuya-sat/micro-dev-loader": "2.2.18",
|
|
24
|
+
"@tuya-sat/micro-dev-proxy": "2.2.18",
|
|
25
|
+
"@tuya-sat/micro-utils": "2.2.18",
|
|
26
26
|
"babel-loader": "8.2.4",
|
|
27
27
|
"babel-plugin-import": "1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|