@tuya-sat/micro-dev-loader 2.3.4 → 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/less/plugin/file.js
CHANGED
|
@@ -4,19 +4,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var path = require('path');
|
|
7
|
-
var fse = require('fs-extra');
|
|
8
7
|
var less = require('less');
|
|
8
|
+
var patch = require('../utils/patch.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
12
12
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
13
|
-
var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
|
|
14
13
|
|
|
15
14
|
class HandleImport extends less.FileManager {
|
|
16
15
|
constructor() {
|
|
17
16
|
super(...arguments);
|
|
18
17
|
this.interceptReg = /antd\/(es|lib)\/style\/themes\/variable\.less$/;
|
|
19
|
-
this.darkVariableContent =
|
|
18
|
+
this.darkVariableContent = patch.getDarkLessContent();
|
|
20
19
|
}
|
|
21
20
|
loadFile(filename, currentDirectory, options, environment) {
|
|
22
21
|
const _super = Object.create(null, {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var semver = require('semver');
|
|
7
|
+
var fse = require('fs-extra');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
12
|
+
var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
|
|
13
|
+
|
|
14
|
+
function patchLessForAntd(version, content) {
|
|
15
|
+
if (semver.gte(version, "4.20.6")) {
|
|
16
|
+
return `${content}@anchor-link-top: 4px;\n`;
|
|
17
|
+
}
|
|
18
|
+
return content;
|
|
19
|
+
}
|
|
20
|
+
function getDarkLessContent() {
|
|
21
|
+
const antdPkgPath = require.resolve('antd/package.json', { paths: [process.cwd()] });
|
|
22
|
+
const { version } = fse__default["default"].readJSONSync(antdPkgPath);
|
|
23
|
+
const originDarkVariableContent = fse__default["default"].readFileSync(path__default["default"].join(__dirname, '../plugin/dark.variable.less'), "utf-8");
|
|
24
|
+
return patchLessForAntd(version, originDarkVariableContent);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.getDarkLessContent = getDarkLessContent;
|
|
28
|
+
exports.patchLessForAntd = patchLessForAntd;
|
|
@@ -35,9 +35,13 @@ class ThemePlugin {
|
|
|
35
35
|
name: this.pluginName,
|
|
36
36
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
37
37
|
}, (assets, callback) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const
|
|
38
|
+
const lightAsset = Object.entries(assets).find(([pathname]) => {
|
|
39
39
|
return /\/light\.[\s\S]+?\.css$/.test(pathname);
|
|
40
40
|
});
|
|
41
|
+
if (!lightAsset) {
|
|
42
|
+
return callback();
|
|
43
|
+
}
|
|
44
|
+
const [pathname] = lightAsset;
|
|
41
45
|
const chunk = compilation.namedChunks.get("light");
|
|
42
46
|
compilation.chunkGraph.getChunkModules(chunk).forEach((item) => {
|
|
43
47
|
this.lessFiles.push(item.nameForCondition());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-dev-loader",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,7 @@
|
|
|
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.
|
|
17
|
+
"@tuya-sat/micro-utils": "2.3.5",
|
|
18
18
|
"cheerio": "1.0.0-rc.10",
|
|
19
19
|
"ejs": "3.1.6",
|
|
20
20
|
"fs-extra": "10.0.1",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"loader-utils": "3.2.0",
|
|
25
25
|
"path": "0.12.7",
|
|
26
26
|
"postcss": "8.4.12",
|
|
27
|
+
"semver": "7.3.5",
|
|
27
28
|
"tslib": "2.3.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|