1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const path = require("path");
|
4 | exports.default = (ctx) => {
|
5 | ctx.registerMethod('generateProjectConfig', ({ srcConfigName, distConfigName }) => {
|
6 | const { appPath, sourcePath, outputPath } = ctx.paths;
|
7 | const { printLog, processTypeEnum, fs } = ctx.helper;
|
8 |
|
9 | const projectConfigFileName = srcConfigName;
|
10 | let projectConfigPath = path.join(appPath, projectConfigFileName);
|
11 | if (!fs.existsSync(projectConfigPath)) {
|
12 |
|
13 | projectConfigPath = path.join(sourcePath, projectConfigFileName);
|
14 | if (!fs.existsSync(projectConfigPath))
|
15 | return;
|
16 | }
|
17 | const origProjectConfig = fs.readJSONSync(projectConfigPath);
|
18 |
|
19 | let distProjectConfig = origProjectConfig;
|
20 | if (origProjectConfig['compileType'] !== 'plugin') {
|
21 | distProjectConfig = Object.assign({}, origProjectConfig, { miniprogramRoot: './' });
|
22 | }
|
23 | ctx.writeFileToDist({
|
24 | filePath: distConfigName,
|
25 | content: JSON.stringify(distProjectConfig, null, 2)
|
26 | });
|
27 | printLog(processTypeEnum.GENERATE, '工具配置', `${outputPath}/${distConfigName}`);
|
28 | });
|
29 | };
|