@plugin-light/shared 1.0.1 → 1.0.2
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,4 +1,14 @@
|
|
|
1
1
|
export type ICrossGameStyleOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* 要替换的样式文件名,不含后缀,默认空,即从项目的 config.js 中获取
|
|
4
|
+
*/
|
|
2
5
|
styleName?: string | Array<string>;
|
|
6
|
+
/**
|
|
7
|
+
* 处理的平台,默认全部,即 ['ALL']
|
|
8
|
+
*/
|
|
3
9
|
platforms?: Array<string>;
|
|
10
|
+
/**
|
|
11
|
+
* 要查找的文件后缀,默认 ['scss', 'less']
|
|
12
|
+
*/
|
|
13
|
+
extList?: Array<string>;
|
|
4
14
|
};
|
package/lib/index.js
CHANGED
|
@@ -500,6 +500,10 @@ const isQuickappUnion = () => getPlatform() === 'quickapp-webview-union';
|
|
|
500
500
|
const isQuickappHuawei = () => getPlatform() === 'quickapp-webview-huawei';
|
|
501
501
|
|
|
502
502
|
const TIP_STYLE_NAME = '@TIP_STYLE_NAME';
|
|
503
|
+
const DEFAULT_EXT_LIST = [
|
|
504
|
+
'scss',
|
|
505
|
+
'less',
|
|
506
|
+
];
|
|
503
507
|
|
|
504
508
|
function getAppDir() {
|
|
505
509
|
if (process.env.VUE_APP_DIR) {
|
|
@@ -535,10 +539,20 @@ function tryRemoveImport(source, removeImport = false) {
|
|
|
535
539
|
}
|
|
536
540
|
return res;
|
|
537
541
|
}
|
|
542
|
+
function findValidFile(fileName, extList) {
|
|
543
|
+
for (const ext of extList) {
|
|
544
|
+
const file = `${fileName}.${ext}`;
|
|
545
|
+
if (fs__namespace.existsSync(file)) {
|
|
546
|
+
return [ext, file];
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return [];
|
|
550
|
+
}
|
|
538
551
|
function crossGameStyle({ source, options, dir, removeImport = false, }) {
|
|
539
552
|
if (!source.includes(TIP_STYLE_NAME)) {
|
|
540
553
|
return source;
|
|
541
554
|
}
|
|
555
|
+
const extList = options?.extList || DEFAULT_EXT_LIST;
|
|
542
556
|
let styleName = '';
|
|
543
557
|
// 使用 env.local 的样式 VUE_APP_DIR = module/ingame-nba,即为 nba
|
|
544
558
|
if (options?.styleName) {
|
|
@@ -566,11 +580,12 @@ function crossGameStyle({ source, options, dir, removeImport = false, }) {
|
|
|
566
580
|
}
|
|
567
581
|
styleName = styleName[0] || '';
|
|
568
582
|
}
|
|
569
|
-
const cssPath = `./css/${styleName}
|
|
570
|
-
const cssAbsolutePath = `${dir}/css/${styleName}
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
573
|
-
|
|
583
|
+
const cssPath = `./css/${styleName}`;
|
|
584
|
+
const cssAbsolutePath = `${dir}/css/${styleName}`;
|
|
585
|
+
const found = findValidFile(cssAbsolutePath, extList);
|
|
586
|
+
if (found.length) {
|
|
587
|
+
const [ext] = found;
|
|
588
|
+
return source.replace(TIP_STYLE_NAME, `${cssPath}.${ext}`);
|
|
574
589
|
}
|
|
575
590
|
return tryRemoveImport(source, removeImport);
|
|
576
591
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugin-light/shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"homepage": "https://novlan1.github.io/docs/plugin-light/zh/plugin-light-shared.html",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/novlan1/plugin-light/issues"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lib/"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"t-comm": "
|
|
19
|
+
"t-comm": "^3.0.3"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "rm -rf lib && rollup -c",
|