@tuya-sat/micro-script 0.0.3 → 1.0.0-rc.3
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.
|
@@ -1,63 +1,5 @@
|
|
|
1
|
+
import { Configuration } from "webpack";
|
|
1
2
|
export default function getCommonConfig({ isDev, isBuild }: {
|
|
2
3
|
isDev: any;
|
|
3
4
|
isBuild: any;
|
|
4
|
-
}):
|
|
5
|
-
mode: string;
|
|
6
|
-
output: {
|
|
7
|
-
filename: string;
|
|
8
|
-
chunkFilename: string;
|
|
9
|
-
path: string;
|
|
10
|
-
clean: boolean;
|
|
11
|
-
library: {
|
|
12
|
-
name: any;
|
|
13
|
-
type: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
module: {
|
|
17
|
-
rules: ({
|
|
18
|
-
test: RegExp;
|
|
19
|
-
use: any[];
|
|
20
|
-
loader?: undefined;
|
|
21
|
-
options?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
test: RegExp;
|
|
24
|
-
use: {
|
|
25
|
-
loader: string;
|
|
26
|
-
options: {
|
|
27
|
-
iesafe: boolean;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
loader?: undefined;
|
|
31
|
-
options?: undefined;
|
|
32
|
-
} | {
|
|
33
|
-
test: RegExp[];
|
|
34
|
-
loader: string;
|
|
35
|
-
options: {
|
|
36
|
-
limit: number;
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
use?: undefined;
|
|
40
|
-
})[];
|
|
41
|
-
};
|
|
42
|
-
optimization: {
|
|
43
|
-
runtimeChunk: string;
|
|
44
|
-
splitChunks: {
|
|
45
|
-
cacheGroups: {
|
|
46
|
-
vendor: {
|
|
47
|
-
test: RegExp;
|
|
48
|
-
name: string;
|
|
49
|
-
chunks: string;
|
|
50
|
-
priority: number;
|
|
51
|
-
};
|
|
52
|
-
react: {
|
|
53
|
-
test: RegExp;
|
|
54
|
-
name: string;
|
|
55
|
-
chunks: string;
|
|
56
|
-
priority: number;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
minimizer: (string | import("css-minimizer-webpack-plugin/types").default<import("css-minimizer-webpack-plugin/types").CssNanoOptionsExtended>)[];
|
|
61
|
-
};
|
|
62
|
-
plugins: any[];
|
|
63
|
-
};
|
|
5
|
+
}): Configuration;
|
|
@@ -23,9 +23,9 @@ function getCommonConfig({ isDev, isBuild }) {
|
|
|
23
23
|
const getStyleLoaders = (cssOptions, extraLoader) => {
|
|
24
24
|
isBuild && cssOptions.importLoaders++;
|
|
25
25
|
const loaders = [
|
|
26
|
-
isBuild ? mini_css_extract_plugin_1.default.loader : "style-loader",
|
|
26
|
+
isBuild ? mini_css_extract_plugin_1.default.loader : require.resolve("style-loader"),
|
|
27
27
|
{
|
|
28
|
-
loader: "css-loader",
|
|
28
|
+
loader: require.resolve("css-loader"),
|
|
29
29
|
options: Object.assign({ modules: {
|
|
30
30
|
auto: true,
|
|
31
31
|
localIdentName: isDev ? "[path][name]__[local]" : "[hash:base64]",
|
|
@@ -37,7 +37,7 @@ function getCommonConfig({ isDev, isBuild }) {
|
|
|
37
37
|
* 默认应该比较新的浏览器了
|
|
38
38
|
*/
|
|
39
39
|
isBuild && {
|
|
40
|
-
loader: "postcss-loader",
|
|
40
|
+
loader: require.resolve("postcss-loader"),
|
|
41
41
|
options: {
|
|
42
42
|
postcssOptions: {
|
|
43
43
|
plugins: ["postcss-preset-env"],
|
|
@@ -76,29 +76,24 @@ function getCommonConfig({ isDev, isBuild }) {
|
|
|
76
76
|
test: /\.less$/,
|
|
77
77
|
use: getStyleLoaders({
|
|
78
78
|
importLoaders: 1,
|
|
79
|
-
}, "less-loader"),
|
|
79
|
+
}, require.resolve("less-loader")),
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
test: /\.(scss|sass)$/,
|
|
83
83
|
use: getStyleLoaders({
|
|
84
84
|
importLoaders: 1,
|
|
85
|
-
}, "sass-loader"),
|
|
85
|
+
}, require.resolve("sass-loader")),
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
|
-
test: /\.svg
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
test: /\.(bmp|png|svg|jpg|jpeg|gif)$/i,
|
|
89
|
+
type: "asset",
|
|
90
|
+
parser: {
|
|
91
|
+
dataUrlCondition: {
|
|
92
|
+
maxSize: 10 * 1024,
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
98
|
-
loader: "url-loader",
|
|
99
|
-
options: {
|
|
100
|
-
limit: 1024 * 10,
|
|
101
|
-
name: "static/media/[name].[hash:8].[ext]",
|
|
95
|
+
generator: {
|
|
96
|
+
filename: "static/img/[hash][ext][query]",
|
|
102
97
|
},
|
|
103
98
|
},
|
|
104
99
|
].filter(Boolean),
|
|
@@ -133,6 +128,7 @@ function getCommonConfig({ isDev, isBuild }) {
|
|
|
133
128
|
{
|
|
134
129
|
from: paths_1.default.publicDir,
|
|
135
130
|
filter: (resourcePath) => __awaiter(this, void 0, void 0, function* () { return !resourcePath.includes(".html"); }),
|
|
131
|
+
noErrorOnMissing: true,
|
|
136
132
|
},
|
|
137
133
|
],
|
|
138
134
|
}),
|
|
@@ -17,25 +17,27 @@ const reactConfig = ({ isDev, isBuild, currentFramework, isTs }) => {
|
|
|
17
17
|
include: paths_1.default.appSrc,
|
|
18
18
|
use: [
|
|
19
19
|
{
|
|
20
|
-
loader: "babel-loader",
|
|
20
|
+
loader: require.resolve("babel-loader"),
|
|
21
21
|
options: {
|
|
22
22
|
presets: [
|
|
23
23
|
[
|
|
24
|
-
"@babel/preset-env",
|
|
24
|
+
require.resolve("@babel/preset-env"),
|
|
25
25
|
{
|
|
26
26
|
useBuiltIns: "entry",
|
|
27
27
|
corejs: 3,
|
|
28
28
|
},
|
|
29
29
|
],
|
|
30
30
|
[
|
|
31
|
-
"@babel/preset-react",
|
|
31
|
+
require.resolve("@babel/preset-react"),
|
|
32
32
|
{
|
|
33
33
|
runtime: "automatic",
|
|
34
34
|
},
|
|
35
35
|
],
|
|
36
|
-
isTs && "@babel/preset-typescript",
|
|
36
|
+
isTs && require.resolve("@babel/preset-typescript"),
|
|
37
|
+
].filter(Boolean),
|
|
38
|
+
plugins: [
|
|
39
|
+
isDev && require.resolve("react-refresh/babel"),
|
|
37
40
|
].filter(Boolean),
|
|
38
|
-
plugins: [isDev && "react-refresh/babel"].filter(Boolean),
|
|
39
41
|
},
|
|
40
42
|
},
|
|
41
43
|
],
|
|
@@ -46,7 +48,7 @@ const reactConfig = ({ isDev, isBuild, currentFramework, isTs }) => {
|
|
|
46
48
|
exclude: paths_1.default.appSrc,
|
|
47
49
|
use: [
|
|
48
50
|
{
|
|
49
|
-
loader: "babel-loader",
|
|
51
|
+
loader: require.resolve("babel-loader"),
|
|
50
52
|
},
|
|
51
53
|
],
|
|
52
54
|
},
|
|
@@ -55,7 +57,7 @@ const reactConfig = ({ isDev, isBuild, currentFramework, isTs }) => {
|
|
|
55
57
|
include: paths_1.default.appSrc,
|
|
56
58
|
use: [
|
|
57
59
|
{
|
|
58
|
-
loader: "@tuya-sat/micro-dev-loader",
|
|
60
|
+
loader: require.resolve("@tuya-sat/micro-dev-loader"),
|
|
59
61
|
options: {
|
|
60
62
|
microFramework: currentFramework,
|
|
61
63
|
},
|
|
@@ -11,31 +11,20 @@ declare const vueTsConfig: ({ isDev, isBuild, currentFramework }: {
|
|
|
11
11
|
use: {
|
|
12
12
|
loader: string;
|
|
13
13
|
options: {
|
|
14
|
-
presets: (string | {
|
|
14
|
+
presets: ((string | {
|
|
15
15
|
useBuiltIns: string;
|
|
16
16
|
corejs: number;
|
|
17
|
-
})[]
|
|
17
|
+
})[] | (string | {
|
|
18
|
+
allExtensions: boolean;
|
|
19
|
+
})[])[];
|
|
18
20
|
};
|
|
19
21
|
}[];
|
|
20
|
-
loader?: undefined;
|
|
21
|
-
options?: undefined;
|
|
22
22
|
} | {
|
|
23
23
|
test: RegExp;
|
|
24
24
|
include: string;
|
|
25
25
|
use: {
|
|
26
26
|
loader: string;
|
|
27
27
|
}[];
|
|
28
|
-
loader?: undefined;
|
|
29
|
-
options?: undefined;
|
|
30
|
-
} | {
|
|
31
|
-
test: RegExp;
|
|
32
|
-
include: string;
|
|
33
|
-
loader: string;
|
|
34
|
-
options: {
|
|
35
|
-
appendTsSuffixTo: RegExp[];
|
|
36
|
-
transpileOnly: boolean;
|
|
37
|
-
};
|
|
38
|
-
use?: undefined;
|
|
39
28
|
} | {
|
|
40
29
|
test: string;
|
|
41
30
|
include: string;
|
|
@@ -45,8 +34,6 @@ declare const vueTsConfig: ({ isDev, isBuild, currentFramework }: {
|
|
|
45
34
|
microFramework: any;
|
|
46
35
|
};
|
|
47
36
|
}[];
|
|
48
|
-
loader?: undefined;
|
|
49
|
-
options?: undefined;
|
|
50
37
|
})[];
|
|
51
38
|
};
|
|
52
39
|
plugins: any[];
|
|
@@ -68,31 +55,20 @@ declare const vueJsConfig: ({ isDev, isBuild, currentFramework }: {
|
|
|
68
55
|
use: {
|
|
69
56
|
loader: string;
|
|
70
57
|
options: {
|
|
71
|
-
presets: (string | {
|
|
58
|
+
presets: ((string | {
|
|
72
59
|
useBuiltIns: string;
|
|
73
60
|
corejs: number;
|
|
74
|
-
})[]
|
|
61
|
+
})[] | (string | {
|
|
62
|
+
allExtensions: boolean;
|
|
63
|
+
})[])[];
|
|
75
64
|
};
|
|
76
65
|
}[];
|
|
77
|
-
loader?: undefined;
|
|
78
|
-
options?: undefined;
|
|
79
66
|
} | {
|
|
80
67
|
test: RegExp;
|
|
81
68
|
include: string;
|
|
82
69
|
use: {
|
|
83
70
|
loader: string;
|
|
84
71
|
}[];
|
|
85
|
-
loader?: undefined;
|
|
86
|
-
options?: undefined;
|
|
87
|
-
} | {
|
|
88
|
-
test: RegExp;
|
|
89
|
-
include: string;
|
|
90
|
-
loader: string;
|
|
91
|
-
options: {
|
|
92
|
-
appendTsSuffixTo: RegExp[];
|
|
93
|
-
transpileOnly: boolean;
|
|
94
|
-
};
|
|
95
|
-
use?: undefined;
|
|
96
72
|
} | {
|
|
97
73
|
test: string;
|
|
98
74
|
include: string;
|
|
@@ -102,8 +78,6 @@ declare const vueJsConfig: ({ isDev, isBuild, currentFramework }: {
|
|
|
102
78
|
microFramework: any;
|
|
103
79
|
};
|
|
104
80
|
}[];
|
|
105
|
-
loader?: undefined;
|
|
106
|
-
options?: undefined;
|
|
107
81
|
})[];
|
|
108
82
|
};
|
|
109
83
|
plugins: any[];
|
|
@@ -16,21 +16,27 @@ const vueConfig = ({ isDev, isBuild, currentFramework, isTs }) => {
|
|
|
16
16
|
module: {
|
|
17
17
|
rules: [
|
|
18
18
|
{
|
|
19
|
-
test: /\.js$/,
|
|
19
|
+
test: /\.(js|ts)$/,
|
|
20
20
|
include: paths_js_1.default.appSrc,
|
|
21
21
|
use: [
|
|
22
22
|
{
|
|
23
|
-
loader: "babel-loader",
|
|
23
|
+
loader: require.resolve("babel-loader"),
|
|
24
24
|
options: {
|
|
25
25
|
presets: [
|
|
26
26
|
[
|
|
27
|
-
"@babel/preset-env",
|
|
27
|
+
require.resolve("@babel/preset-env"),
|
|
28
28
|
{
|
|
29
29
|
useBuiltIns: "entry",
|
|
30
30
|
corejs: 3,
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
|
-
|
|
33
|
+
isTs && [
|
|
34
|
+
require.resolve("@babel/preset-typescript"),
|
|
35
|
+
{
|
|
36
|
+
allExtensions: true,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
].filter(Boolean),
|
|
34
40
|
},
|
|
35
41
|
},
|
|
36
42
|
],
|
|
@@ -40,22 +46,16 @@ const vueConfig = ({ isDev, isBuild, currentFramework, isTs }) => {
|
|
|
40
46
|
include: paths_js_1.default.appSrc,
|
|
41
47
|
use: [
|
|
42
48
|
{
|
|
43
|
-
loader: "vue-loader",
|
|
49
|
+
loader: require.resolve("vue-loader"),
|
|
44
50
|
},
|
|
45
51
|
],
|
|
46
52
|
},
|
|
47
|
-
isTs && {
|
|
48
|
-
test: /\.ts$/,
|
|
49
|
-
include: paths_js_1.default.appSrc,
|
|
50
|
-
loader: "ts-loader",
|
|
51
|
-
options: { appendTsSuffixTo: [/\.vue$/], transpileOnly: true },
|
|
52
|
-
},
|
|
53
53
|
isDev && {
|
|
54
54
|
test: isTs ? paths_js_1.default.vueTsEntryFile : paths_js_1.default.vueJsEntryFile,
|
|
55
55
|
include: paths_js_1.default.appSrc,
|
|
56
56
|
use: [
|
|
57
57
|
{
|
|
58
|
-
loader: "@tuya-sat/micro-dev-loader",
|
|
58
|
+
loader: require.resolve("@tuya-sat/micro-dev-loader"),
|
|
59
59
|
options: {
|
|
60
60
|
microFramework: currentFramework,
|
|
61
61
|
},
|
package/dist/scripts/start.js
CHANGED
|
@@ -47,7 +47,7 @@ new micro_dev_loader_1.LayoutMockPlugin().apply(compiler);
|
|
|
47
47
|
"Access-Control-Allow-Origin": "*",
|
|
48
48
|
"Access-Control-Allow-Headers": "*",
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
setupMiddlewares(middlewares, { app }) {
|
|
51
51
|
micro_dev_loader_1.LayoutMockPlugin.useLayoutStatic(app);
|
|
52
52
|
(0, mock_1.default)(app);
|
|
53
53
|
if (isProxy) {
|
|
@@ -55,6 +55,7 @@ new micro_dev_loader_1.LayoutMockPlugin().apply(compiler);
|
|
|
55
55
|
const { debuggerConfig } = require(paths_1.default.microConfig);
|
|
56
56
|
createProxy(debuggerConfig)(app);
|
|
57
57
|
}
|
|
58
|
+
return middlewares;
|
|
58
59
|
},
|
|
59
60
|
}, compiler);
|
|
60
61
|
compiler.hooks.watchRun.tap("MyPlugin", () => {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "0.0.3",
|
|
3
|
+
"version": "1.0.0-rc.3",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"dev": "tsc --watch",
|
|
8
|
+
"dev": "rm -rf dist/ && tsc --watch",
|
|
9
9
|
"build": "rm -rf dist/ && tsc",
|
|
10
10
|
"prepublish": "yarn build"
|
|
11
11
|
},
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"@babel/preset-react": "^7.14.5",
|
|
16
16
|
"@babel/preset-typescript": "^7.15.0",
|
|
17
17
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
18
|
-
"@tuya-sat/micro-dev-loader": "0.0.3",
|
|
19
|
-
"@tuya-sat/micro-dev-proxy": "0.0.3",
|
|
18
|
+
"@tuya-sat/micro-dev-loader": "1.0.0-rc.3",
|
|
19
|
+
"@tuya-sat/micro-dev-proxy": "1.0.0-rc.3",
|
|
20
20
|
"babel-loader": "^8.2.2",
|
|
21
21
|
"babel-plugin-import": "^1.13.3",
|
|
22
|
+
"chalk": "4.1.2",
|
|
22
23
|
"copy-webpack-plugin": "^9.0.1",
|
|
23
24
|
"css-loader": "^6.4.0",
|
|
24
25
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"ora": "5.4.1",
|
|
31
32
|
"path-to-regexp": "^6.2.0",
|
|
32
33
|
"portfinder": "^1.0.28",
|
|
34
|
+
"postcss": "^8.4.5",
|
|
33
35
|
"postcss-loader": "^6.1.1",
|
|
34
36
|
"postcss-preset-env": "^6.7.0",
|
|
35
37
|
"react-refresh": "^0.10.0",
|
|
@@ -38,7 +40,6 @@
|
|
|
38
40
|
"sass-loader": "^12.1.0",
|
|
39
41
|
"style-loader": "^3.3.0",
|
|
40
42
|
"svg-url-loader": "^7.1.1",
|
|
41
|
-
"ts-loader": "^9.2.6",
|
|
42
43
|
"tsconfig-paths-webpack-plugin": "^3.5.1",
|
|
43
44
|
"url-loader": "^4.1.1",
|
|
44
45
|
"vue-loader": "16.8.2",
|
|
@@ -57,5 +58,6 @@
|
|
|
57
58
|
"saas",
|
|
58
59
|
"cloud",
|
|
59
60
|
"tuya"
|
|
60
|
-
]
|
|
61
|
+
],
|
|
62
|
+
"stableVersion": "0.0.4"
|
|
61
63
|
}
|