@cloudbase/framework-plugin-low-code 0.6.30 → 0.6.33
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/lib/builder/config/index.js +2 -5
- package/lib/builder/core/copy.d.ts.map +1 -1
- package/lib/builder/mp/materials.d.ts.map +1 -1
- package/lib/builder/mp/materials.js +21 -5
- package/package.json +5 -3
- package/template/src/handlers/FieldMiddleware/renderer.jsx +11 -6
- package/template/src/handlers/actionHandler/utils.js +41 -17
- package/template/webpack/web.prod.js +65 -85
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/cookie.js +0 -286
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/history.js +0 -133
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/local-storage.js +0 -103
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/location.js +0 -588
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/miniprogram.js +0 -101
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/navigator.js +0 -80
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/performance.js +0 -28
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/screen.js +0 -31
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/session-storage.js +0 -96
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/xml-http-request.js +0 -290
- package/template/dist/mp/miniprogram_npm/miniprogram-render/document.js +0 -396
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/custom-event.js +0 -12
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event-target.js +0 -389
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event.js +0 -186
- package/template/dist/mp/miniprogram_npm/miniprogram-render/index.js +0 -41
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/attribute.js +0 -226
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/class-list.js +0 -153
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/comment.js +0 -80
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/a.js +0 -165
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/canvas.js +0 -138
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/image.js +0 -177
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/input.js +0 -181
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/not-support.js +0 -60
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/option.js +0 -126
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/select.js +0 -155
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/textarea.js +0 -178
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/video.js +0 -165
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-component.js +0 -84
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-custom-component.js +0 -64
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element.js +0 -970
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/node.js +0 -140
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style-list.js +0 -28
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style.js +0 -158
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/text-node.js +0 -127
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/parser.js +0 -269
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/query-selector.js +0 -420
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/tree.js +0 -130
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/cache.js +0 -95
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/pool.js +0 -24
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/tool.js +0 -131
- package/template/dist/mp/miniprogram_npm/miniprogram-render/window.js +0 -651
- package/template/generator/app/common.js +0 -17
- package/template/generator/app/global-api.js +0 -163
- package/template/generator/app/handlers.js +0 -13
- package/template/generator/datasources/config.js.tpl +0 -21
- package/template/generator/datasources/dataset-profiles.js.tpl +0 -5
- package/template/generator/datasources/datasource-profiles.js.tpl +0 -4
- package/template/generator/datasources/index.js.tpl +0 -14
- package/template/generator/handlers/NodeRenderer.jsx +0 -471
- package/template/generator/handlers/RenderWrapper.jsx +0 -145
- package/template/generator/index.jsx +0 -116
- package/template/generator/index.less +0 -120
- package/template/generator/pages/app.tpl +0 -181
- package/template/generator/pages/composite.tpl +0 -267
- package/template/generator/router/index.tpl +0 -49
- package/template/generator/store/computed.js +0 -11
- package/template/generator/store/index.js +0 -5
- package/template/generator/utils/ScanCodeComponent.js +0 -345
- package/template/generator/utils/actionHandler.js +0 -119
- package/template/generator/utils/common.js +0 -225
- package/template/generator/utils/computed.js +0 -9
- package/template/generator/utils/date.js +0 -324
- package/template/generator/utils/error.jsx +0 -14
- package/template/generator/utils/eventProxy.js +0 -64
- package/template/generator/utils/history.js +0 -35
- package/template/generator/utils/hooks.js +0 -10
- package/template/generator/utils/index.js +0 -41
- package/template/generator/utils/initGlobalVar.js +0 -14
- package/template/generator/utils/lifecycle.js +0 -158
- package/template/generator/utils/monitor-jssdk.min.js +0 -881
- package/template/generator/utils/page.js +0 -10
- package/template/generator/utils/scan-code-action.js +0 -27
- package/template/generator/utils/style.js +0 -81
- package/template/generator/utils/widgets.js +0 -343
|
@@ -21,12 +21,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
22
|
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
23
23
|
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
25
|
exports.sharedMaterialsDir = void 0;
|
|
29
26
|
const path = __importStar(require("path"));
|
|
30
|
-
const
|
|
27
|
+
const os = __importStar(require("os"));
|
|
31
28
|
__exportStar(require("../../generator/config/index"), exports);
|
|
32
|
-
exports.sharedMaterialsDir = path.join(
|
|
29
|
+
exports.sharedMaterialsDir = path.join(os.homedir(), '.weapps-materials');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../src/builder/core/copy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../src/builder/core/copy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAM7D,wBAAsB,OAAO,CAC3B,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,kBAAkB,EACrC,OAAO,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,iBAwBpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materials.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/materials.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,uBAAuB,EAIxB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAU/C,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,EAAE,EACpB,GAAG,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"materials.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/materials.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,uBAAuB,EAIxB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAU/C,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,EAAE,EACpB,GAAG,EAAE,aAAa,iBAkNnB;AAGD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,UAAU,EACjB,YAAY,EAAE,oBAAoB,EAAE,EACpC,cAAc,EAAE,aAAa,EAAE,EAC/B,WAAW,CAAC,EAAE,UAAU,cAsCzB;AA6ID,wBAAgB,UAAU,CACxB,GAAG,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,YAAY,CAAC,EACpD,GAAG,EAAE,aAAa,EAClB,WAAW,CAAC,EAAE,WAAW;;;;;;EA8D1B"}
|
|
@@ -85,8 +85,22 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
85
85
|
else {
|
|
86
86
|
usingMaterialMap[targetDir] = true;
|
|
87
87
|
}
|
|
88
|
+
const materialsSrcDirPath = path.join(materialsSrcDir, 'src');
|
|
89
|
+
const compGroupIndexJson = yield fs.readJSON(path.join(materialsSrcDirPath, 'index.json'));
|
|
90
|
+
const componentsPathMap = compGroupIndexJson.components;
|
|
91
|
+
const dirsToDelete = [];
|
|
92
|
+
const componentsJson = Object.keys(componentsPathMap).reduce((acc, compName) => {
|
|
93
|
+
if (usedComps[name].has(compName)) {
|
|
94
|
+
acc[compName] = componentsPathMap[compName];
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
if (typeof componentsPathMap[compName] === 'string') {
|
|
98
|
+
dirsToDelete.push(path.join(targetDir, path.dirname(componentsPathMap[compName])));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return acc;
|
|
102
|
+
}, {});
|
|
88
103
|
if (libUpdated(targetDir, version)) {
|
|
89
|
-
const materialsSrcDirPath = path.join(materialsSrcDir, 'src');
|
|
90
104
|
if (fs.existsSync(materialsSrcDirPath)) {
|
|
91
105
|
console.log(`Copying material ${materialId} from ${materialsSrcDir}/src to ${targetDir}`);
|
|
92
106
|
const metaJosnPath = path.join(materialsSrcDir, 'meta.json');
|
|
@@ -95,8 +109,7 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
95
109
|
}
|
|
96
110
|
yield fs.copy(materialsSrcDirPath, targetDir, {
|
|
97
111
|
filter: function (src, dest) {
|
|
98
|
-
|
|
99
|
-
return !junk.is(path[path.length - 1]);
|
|
112
|
+
return !junk.is(path.basename(src));
|
|
100
113
|
},
|
|
101
114
|
});
|
|
102
115
|
}
|
|
@@ -104,12 +117,15 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
104
117
|
console.log(`Copying material ${materialId} from ${materialsSrcDir} to ${targetDir}`);
|
|
105
118
|
yield fs.copy(materialsSrcDir, targetDir, {
|
|
106
119
|
filter: function (src, dest) {
|
|
107
|
-
|
|
108
|
-
return !junk.is(path[path.length - 1]);
|
|
120
|
+
return !junk.is(path.basename(src));
|
|
109
121
|
},
|
|
110
122
|
});
|
|
111
123
|
}
|
|
112
124
|
}
|
|
125
|
+
yield fs.writeJSON(path.join(targetDir, 'index.json'), Object.assign(Object.assign({}, compGroupIndexJson), { components: componentsJson }), { spaces: 2 });
|
|
126
|
+
yield Promise.all(dirsToDelete.map((dir) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
fs.remove(dir);
|
|
128
|
+
})));
|
|
113
129
|
const libMeta = util_4.readComponentLibMata(targetDir);
|
|
114
130
|
if (!lib.components) {
|
|
115
131
|
lib.components = Object.keys((libMeta === null || libMeta === void 0 ? void 0 : libMeta.components) || {}).map((name) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.33",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"dev": "tsc -w",
|
|
29
29
|
"prebuild": "rm -rf ./lib && rm -rf ./tsconfig.tsbuildinfo && npm run template",
|
|
30
30
|
"build": "tsc",
|
|
31
|
-
"test": "jest"
|
|
31
|
+
"test": "jest",
|
|
32
|
+
"link": "node scripts/link-packages.js"
|
|
32
33
|
},
|
|
33
34
|
"bugs": {
|
|
34
35
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"xml-js": "^1.6.11"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
74
|
+
"@lerna/create-symlink": "^4.0.0",
|
|
73
75
|
"@types/archiver": "^3.1.0",
|
|
74
76
|
"@types/command-exists": "^1.2.0",
|
|
75
77
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -85,4 +87,4 @@
|
|
|
85
87
|
"jest": "^26.0.1",
|
|
86
88
|
"typescript": "^3.8.3"
|
|
87
89
|
}
|
|
88
|
-
}
|
|
90
|
+
}
|
|
@@ -63,7 +63,7 @@ export const CompRenderer = observer(function (props) {
|
|
|
63
63
|
|
|
64
64
|
// 组件最终用于执行的事件函数
|
|
65
65
|
const emit = useCallback(
|
|
66
|
-
(trigger,
|
|
66
|
+
(trigger, eventDetail, forItems, scopeContext) => {
|
|
67
67
|
const listeners = listenerInstances || [];
|
|
68
68
|
|
|
69
69
|
// 如果是数据容器,则将传过来的data,赋值给容器上下文context
|
|
@@ -83,7 +83,7 @@ export const CompRenderer = observer(function (props) {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
event = { detail:
|
|
86
|
+
let event = { detail: eventDetail, name: trigger };
|
|
87
87
|
forItems = {
|
|
88
88
|
...forItems,
|
|
89
89
|
forIndexes: getForIndexes(forItems, widgetsData),
|
|
@@ -105,14 +105,14 @@ export const CompRenderer = observer(function (props) {
|
|
|
105
105
|
|
|
106
106
|
// 选区最终用于执行的事件函数
|
|
107
107
|
const emitSB = useCallback(
|
|
108
|
-
(trigger,
|
|
108
|
+
(trigger, eventDetail, forItems, scopeContext, fieldData) => {
|
|
109
109
|
const listeners =
|
|
110
110
|
indexRef?.current !== undefined &&
|
|
111
111
|
typeRef?.current &&
|
|
112
112
|
fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[
|
|
113
113
|
'x-props'
|
|
114
114
|
]?.listenerInstances;
|
|
115
|
-
event = { detail:
|
|
115
|
+
let event = { detail: eventDetail, name: trigger };
|
|
116
116
|
forItems = {
|
|
117
117
|
...forItems,
|
|
118
118
|
forIndexes: getForIndexes(forItems, widgetsData),
|
|
@@ -164,7 +164,9 @@ export const CompRenderer = observer(function (props) {
|
|
|
164
164
|
try {
|
|
165
165
|
// 绑定了 for 变量,但计算值错误时,应当空数组兜底
|
|
166
166
|
forList =
|
|
167
|
-
dataBinds &&
|
|
167
|
+
dataBinds &&
|
|
168
|
+
dataBinds._waFor &&
|
|
169
|
+
(dataBinds._waFor(parentForItems, undefined, context) || []);
|
|
168
170
|
} catch (e) {
|
|
169
171
|
// 计算值出错则使用空数组兜底
|
|
170
172
|
forList = [];
|
|
@@ -305,7 +307,10 @@ export const CompRenderer = observer(function (props) {
|
|
|
305
307
|
|
|
306
308
|
return (
|
|
307
309
|
<Field
|
|
308
|
-
data={{
|
|
310
|
+
data={{
|
|
311
|
+
...fieldData,
|
|
312
|
+
_selectableBlockEvents: _selectableBlockEventsWithItem,
|
|
313
|
+
}}
|
|
309
314
|
id={compId}
|
|
310
315
|
{...componentProps}
|
|
311
316
|
emit={emitWithForItems}
|
|
@@ -11,31 +11,44 @@ export function getMetaInfoBySourceKey(sourceKey) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function emitEvent(
|
|
14
|
+
export function emitEvent(
|
|
15
|
+
trigger,
|
|
16
|
+
listeners = [],
|
|
17
|
+
args,
|
|
18
|
+
scopeContext = {},
|
|
19
|
+
context
|
|
20
|
+
) {
|
|
15
21
|
const targetListeners = listeners.filter((l) => l.trigger === trigger);
|
|
16
22
|
targetListeners.forEach(async (listener) => {
|
|
17
23
|
// 当前非捕获Event,再判断冒泡行为
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
listener.noPropagation
|
|
21
|
-
) {
|
|
22
|
-
args?.customEventData?.detail?.stopPropagation();
|
|
24
|
+
if (!args?.event?.isCapturePhase && listener.noPropagation) {
|
|
25
|
+
args?.customEventData?.stopPropagation();
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
// 判断捕获的执行,只有执行的捕获与配置的捕获一致时。才会执行。
|
|
26
29
|
if (
|
|
27
30
|
(listener?.isCapturePhase || false) ===
|
|
28
|
-
(args?.customEventData?.
|
|
31
|
+
(args?.customEventData?.isCapturePhase || false)
|
|
29
32
|
) {
|
|
30
33
|
try {
|
|
31
34
|
const res = await invokeListener(listener, args, scopeContext, context);
|
|
32
35
|
const eventName = `${listener.key}.success`;
|
|
33
36
|
const event = {
|
|
34
|
-
detail:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
detail:
|
|
38
|
+
typeof res === 'object' && res !== null && !Array.isArray(res)
|
|
39
|
+
? {
|
|
40
|
+
...res,
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated 历史bug
|
|
43
|
+
* value,origin,isCapturePhase
|
|
44
|
+
*/
|
|
45
|
+
value: res,
|
|
46
|
+
origin: args.event,
|
|
47
|
+
isCapturePhase: !!args.event?.isCapturePhase,
|
|
48
|
+
}
|
|
49
|
+
: res,
|
|
50
|
+
origin: args.event,
|
|
51
|
+
isCapturePhase: !!args.event?.isCapturePhase,
|
|
39
52
|
name: eventName,
|
|
40
53
|
};
|
|
41
54
|
emitEvent(
|
|
@@ -49,14 +62,22 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}, cont
|
|
|
49
62
|
scopeContext,
|
|
50
63
|
context
|
|
51
64
|
);
|
|
65
|
+
if (res) {
|
|
66
|
+
console.warn(
|
|
67
|
+
`@deprecated 事件编排中后续事件(${eventName}) event.detail.value.xxx 已废弃,建议使用 event.detail 直接访问前一动作返回值`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
52
70
|
} catch (e) {
|
|
53
71
|
const eventName = `${listener.key}.fail`;
|
|
72
|
+
try {
|
|
73
|
+
e.value = e;
|
|
74
|
+
e.origin = args.event;
|
|
75
|
+
e.isCapturePhase = !!args.event?.isCapturePhase;
|
|
76
|
+
} catch (e) {}
|
|
54
77
|
const event = {
|
|
55
|
-
detail:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
isCapturePhase: !!args.event?.isCapturePhase,
|
|
59
|
-
},
|
|
78
|
+
detail: e,
|
|
79
|
+
origin: args.event,
|
|
80
|
+
isCapturePhase: !!args.event?.isCapturePhase,
|
|
60
81
|
name: eventName,
|
|
61
82
|
};
|
|
62
83
|
emitEvent(
|
|
@@ -70,6 +91,9 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}, cont
|
|
|
70
91
|
scopeContext,
|
|
71
92
|
context
|
|
72
93
|
);
|
|
94
|
+
console.warn(
|
|
95
|
+
`@deprecated 事件编排中后续事件(${eventName}) event.detail.value.xxx 已废弃,建议使用 event.detail 直接访问前一动作返回值`
|
|
96
|
+
);
|
|
73
97
|
// 之前 invoke 内部catch 了错误,不会抛错
|
|
74
98
|
// throw e
|
|
75
99
|
}
|
|
@@ -92,22 +92,16 @@ module.exports = function (options) {
|
|
|
92
92
|
threadMode: true,
|
|
93
93
|
loaders: {
|
|
94
94
|
js: [babelLoader],
|
|
95
|
-
ts: [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
],
|
|
99
|
-
}
|
|
100
|
-
}
|
|
95
|
+
ts: [babelLoader, typescriptLoader],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
101
98
|
},
|
|
102
99
|
],
|
|
103
|
-
threadPool: happyThreadPool
|
|
100
|
+
threadPool: happyThreadPool,
|
|
104
101
|
}),
|
|
105
102
|
new HappyPack({
|
|
106
103
|
id: TS_LOADER_ID,
|
|
107
|
-
loaders: [
|
|
108
|
-
babelLoader,
|
|
109
|
-
typescriptLoader,
|
|
110
|
-
],
|
|
104
|
+
loaders: [babelLoader, typescriptLoader],
|
|
111
105
|
threadPool: happyThreadPool,
|
|
112
106
|
}),
|
|
113
107
|
new HappyPack({
|
|
@@ -125,13 +119,15 @@ module.exports = function (options) {
|
|
|
125
119
|
filename: '[name].[contenthash].css',
|
|
126
120
|
chunkFilename: '[id].[contenthash].css',
|
|
127
121
|
}),
|
|
128
|
-
new webpack.DefinePlugin(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
new webpack.DefinePlugin(
|
|
123
|
+
Object.assign(
|
|
124
|
+
{
|
|
125
|
+
'process.env.isMiniprogram': false, // 注入环境变量,用于业务代码判断
|
|
126
|
+
'process.env.SSR': false,
|
|
127
|
+
},
|
|
128
|
+
definePlugin
|
|
129
|
+
)
|
|
130
|
+
),
|
|
135
131
|
new CopyWebpackPlugin({
|
|
136
132
|
patterns: [
|
|
137
133
|
{
|
|
@@ -157,6 +153,36 @@ module.exports = function (options) {
|
|
|
157
153
|
}),
|
|
158
154
|
]);
|
|
159
155
|
}
|
|
156
|
+
|
|
157
|
+
const cssLoaders = [
|
|
158
|
+
MiniCssExtractPlugin.loader,
|
|
159
|
+
{
|
|
160
|
+
loader: 'css-loader',
|
|
161
|
+
options: {
|
|
162
|
+
modules: false,
|
|
163
|
+
importLoaders: 2,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
loader: 'postcss-loader',
|
|
168
|
+
options: {
|
|
169
|
+
postcssOptions: {
|
|
170
|
+
plugins: [
|
|
171
|
+
[
|
|
172
|
+
'postcss-pxtorem',
|
|
173
|
+
{
|
|
174
|
+
rootValue: 14,
|
|
175
|
+
propList: ['*'],
|
|
176
|
+
// todo
|
|
177
|
+
selectorBlackList: ['.weui-picker__indicator'],
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
|
|
160
186
|
return {
|
|
161
187
|
context,
|
|
162
188
|
entry,
|
|
@@ -184,7 +210,7 @@ module.exports = function (options) {
|
|
|
184
210
|
rules: [
|
|
185
211
|
{
|
|
186
212
|
test: /\.vue$/,
|
|
187
|
-
loader: 'happypack/loader?id=vue'
|
|
213
|
+
loader: 'happypack/loader?id=vue',
|
|
188
214
|
},
|
|
189
215
|
{
|
|
190
216
|
test: /\.tsx?$/,
|
|
@@ -199,32 +225,7 @@ module.exports = function (options) {
|
|
|
199
225
|
{
|
|
200
226
|
test: /\.(scss|sass)$/,
|
|
201
227
|
use: [
|
|
202
|
-
|
|
203
|
-
{
|
|
204
|
-
loader: 'css-loader',
|
|
205
|
-
options: {
|
|
206
|
-
modules: false,
|
|
207
|
-
importLoaders: 2,
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
loader: 'postcss-loader',
|
|
212
|
-
options: {
|
|
213
|
-
postcssOptions: {
|
|
214
|
-
plugins: [
|
|
215
|
-
[
|
|
216
|
-
'postcss-pxtorem',
|
|
217
|
-
{
|
|
218
|
-
rootValue: 14,
|
|
219
|
-
propList: ['*'],
|
|
220
|
-
// todo
|
|
221
|
-
selectorBlackList: ['.weui-picker__indicator'],
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
],
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
+
...cssLoaders,
|
|
228
229
|
{
|
|
229
230
|
loader: 'sass-loader',
|
|
230
231
|
options: {
|
|
@@ -234,34 +235,13 @@ module.exports = function (options) {
|
|
|
234
235
|
],
|
|
235
236
|
},
|
|
236
237
|
{
|
|
237
|
-
test: /\.
|
|
238
|
+
test: /\.css$/,
|
|
239
|
+
use: [...cssLoaders],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
test: /\.less$/,
|
|
238
243
|
use: [
|
|
239
|
-
|
|
240
|
-
{
|
|
241
|
-
loader: 'css-loader',
|
|
242
|
-
options: {
|
|
243
|
-
modules: false,
|
|
244
|
-
importLoaders: 2,
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
loader: 'postcss-loader',
|
|
249
|
-
options: {
|
|
250
|
-
postcssOptions: {
|
|
251
|
-
plugins: [
|
|
252
|
-
[
|
|
253
|
-
'postcss-pxtorem',
|
|
254
|
-
{
|
|
255
|
-
rootValue: 14,
|
|
256
|
-
propList: ['*'],
|
|
257
|
-
// todo
|
|
258
|
-
selectorBlackList: ['.weui-picker__indicator'],
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
],
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
},
|
|
244
|
+
...cssLoaders,
|
|
265
245
|
{
|
|
266
246
|
loader: 'less-loader',
|
|
267
247
|
options: {
|
|
@@ -310,20 +290,20 @@ module.exports = function (options) {
|
|
|
310
290
|
},
|
|
311
291
|
...(isDevelopment
|
|
312
292
|
? {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
293
|
+
minimize: false,
|
|
294
|
+
removeAvailableModules: false,
|
|
295
|
+
removeEmptyChunks: true,
|
|
296
|
+
}
|
|
317
297
|
: {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
298
|
+
minimizer: [
|
|
299
|
+
new TerserPlugin({
|
|
300
|
+
test: /\.js(\?.*)?$/i,
|
|
301
|
+
cache: false,
|
|
302
|
+
parallel: true,
|
|
303
|
+
sourceMap: false,
|
|
304
|
+
}),
|
|
305
|
+
],
|
|
306
|
+
}),
|
|
327
307
|
},
|
|
328
308
|
};
|
|
329
309
|
};
|