@tuya-sat/micro-dev-loader 2.3.0-rc.1 → 2.3.0
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/index.d.ts +1 -2
- package/dist/index.js +0 -2
- package/package.json +3 -5
- package/dist/plugins/locales/index.d.ts +0 -9
- package/dist/plugins/locales/index.js +0 -66
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import ThemePlugin from "./plugins/theme";
|
|
2
|
-
import LocalesPlugin from "./plugins/locales";
|
|
3
2
|
declare const filterCssVariableLoader: string;
|
|
4
3
|
declare const changeAntdGlobalImport: string;
|
|
5
4
|
declare const changeTuyaSatComponentImport: string;
|
|
6
|
-
export { ThemePlugin,
|
|
5
|
+
export { ThemePlugin, filterCssVariableLoader, changeAntdGlobalImport, changeTuyaSatComponentImport };
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var index = require('./plugins/theme/index.js');
|
|
6
|
-
var index$1 = require('./plugins/locales/index.js');
|
|
7
6
|
|
|
8
7
|
const filterCssVariableLoader = require.resolve("./loader/filterCssVariableLoader");
|
|
9
8
|
const changeAntdGlobalImport = require.resolve("./loader/changeAntdGlobalImport");
|
|
10
9
|
const changeTuyaSatComponentImport = require.resolve("./loader/changeTuyaSatComponentImport");
|
|
11
10
|
|
|
12
11
|
exports.ThemePlugin = index["default"];
|
|
13
|
-
exports.LocalesPlugin = index$1["default"];
|
|
14
12
|
exports.changeAntdGlobalImport = changeAntdGlobalImport;
|
|
15
13
|
exports.changeTuyaSatComponentImport = changeTuyaSatComponentImport;
|
|
16
14
|
exports.filterCssVariableLoader = filterCssVariableLoader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-dev-loader",
|
|
3
|
-
"version": "2.3.0
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
"@babel/generator": "7.17.7",
|
|
15
15
|
"@babel/plugin-syntax-typescript": "7.16.7",
|
|
16
16
|
"@babel/template": "7.16.7",
|
|
17
|
-
"@tuya-sat/micro-utils": "2.3.0
|
|
17
|
+
"@tuya-sat/micro-utils": "2.3.0",
|
|
18
18
|
"cheerio": "1.0.0-rc.10",
|
|
19
19
|
"ejs": "3.1.6",
|
|
20
20
|
"fs-extra": "10.0.1",
|
|
21
21
|
"html-webpack-plugin": "5.5.0",
|
|
22
|
-
"jiti": "1.14.0",
|
|
23
22
|
"less": "4.1.2",
|
|
24
23
|
"less-bundle-promise": "1.0.11",
|
|
25
24
|
"loader-utils": "3.2.0",
|
|
@@ -49,6 +48,5 @@
|
|
|
49
48
|
"saas",
|
|
50
49
|
"cloud",
|
|
51
50
|
"tuya"
|
|
52
|
-
]
|
|
53
|
-
"stableVersion": "2.2.30"
|
|
51
|
+
]
|
|
54
52
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Compiler } from "webpack";
|
|
2
|
-
export default class LocalsPlugin {
|
|
3
|
-
private localesOriginPath;
|
|
4
|
-
private localesTargetPath;
|
|
5
|
-
private pluginName;
|
|
6
|
-
private localesFiles;
|
|
7
|
-
constructor(localesOriginPath?: string, localesTargetPath?: string);
|
|
8
|
-
apply(compiler: Compiler): void;
|
|
9
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var fs = require('fs');
|
|
7
|
-
var path = require('path');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
12
|
-
|
|
13
|
-
class LocalsPlugin {
|
|
14
|
-
constructor(localesOriginPath = "./src/lang", localesTargetPath = "./_locales/ui") {
|
|
15
|
-
this.localesOriginPath = localesOriginPath;
|
|
16
|
-
this.localesTargetPath = localesTargetPath;
|
|
17
|
-
this.pluginName = "LocalsPlugin";
|
|
18
|
-
this.localesFiles = [];
|
|
19
|
-
}
|
|
20
|
-
apply(compiler) {
|
|
21
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
22
|
-
if (isProduction) {
|
|
23
|
-
compiler.hooks.thisCompilation.tap(this.pluginName, (compilation) => {
|
|
24
|
-
compilation.hooks.processAssets.tapAsync({
|
|
25
|
-
name: this.pluginName,
|
|
26
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
27
|
-
}, (assets, callback) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const filenames = yield fs__default["default"].readdirSync(this.localesOriginPath);
|
|
29
|
-
fs__default["default"].rmdirSync(path.resolve(this.localesTargetPath), {
|
|
30
|
-
recursive: true,
|
|
31
|
-
});
|
|
32
|
-
fs__default["default"].mkdirSync(path.resolve(this.localesTargetPath));
|
|
33
|
-
const jiti = require("jiti")(path.resolve(this.localesOriginPath));
|
|
34
|
-
filenames.forEach((v) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
var _a;
|
|
36
|
-
if (v === "index.ts")
|
|
37
|
-
return;
|
|
38
|
-
const lang = v.split(".")[0];
|
|
39
|
-
const content = jiti(`./${v}`);
|
|
40
|
-
console.log("yongsi content", content);
|
|
41
|
-
const resObj = {};
|
|
42
|
-
const recursive = (value, prefix, key) => {
|
|
43
|
-
if (typeof value === "object") {
|
|
44
|
-
prefix += `.${key}`;
|
|
45
|
-
Object.keys(value).forEach((k) => {
|
|
46
|
-
recursive(value[k], prefix, k);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
key = `${prefix}.${key}`.substring(2);
|
|
51
|
-
resObj[key] = value;
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
recursive((_a = content.default) === null || _a === void 0 ? void 0 : _a.translation, "", "");
|
|
56
|
-
const resJson = JSON.stringify(resObj);
|
|
57
|
-
fs__default["default"].appendFileSync(path.resolve(`${this.localesTargetPath}/${lang}.json`), resJson);
|
|
58
|
-
}));
|
|
59
|
-
callback();
|
|
60
|
-
}));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exports["default"] = LocalsPlugin;
|