|
|
@@ -10,7 +10,7 @@ function customPlugin(): HvigorPlugin {
|
|
|
apply(node: HvigorNode) {
|
|
|
try {
|
|
|
|
|
|
- console.log('node', JSON.stringify(node))
|
|
|
+ // console.log('node', JSON.stringify(node))
|
|
|
// 根据node对象结构获取项目路径
|
|
|
const projectPath = node.nodeDir.filePath;
|
|
|
console.log('目标路径:', projectPath);
|
|
|
@@ -166,14 +166,14 @@ function customPlugin(): HvigorPlugin {
|
|
|
if (fs.existsSync(moduleJsonPath)) {
|
|
|
const moduleJsonContent = fs.readFileSync(moduleJsonPath, 'utf8');
|
|
|
|
|
|
- // 使用正则表达式在"type": "entry"后添加routerMap字段
|
|
|
- if (moduleJsonContent.includes('"name"')) {
|
|
|
+ // 使用正则表达式在"module": {后添加routerMap字段
|
|
|
+ if (moduleJsonContent.includes('"module"')) {
|
|
|
// 检查是否已经存在routerMap字段
|
|
|
if (!moduleJsonContent.includes('"routerMap"')) {
|
|
|
- // 在"type": "entry"后添加routerMap字段
|
|
|
+ // 在"module": {后添加routerMap字段
|
|
|
const updatedContent = moduleJsonContent.replace(
|
|
|
- /("type":\s*"entry"[,\s\n\r]*)/,
|
|
|
- '$1"routerMap": "$profile:router_map",\n '
|
|
|
+ /("module"\s*:\s*{)/,
|
|
|
+ '$1\n "routerMap": "$profile:router_map",'
|
|
|
);
|
|
|
|
|
|
fs.writeFileSync(moduleJsonPath, updatedContent, 'utf8');
|
|
|
@@ -182,7 +182,7 @@ function customPlugin(): HvigorPlugin {
|
|
|
console.log('module.json5中已存在routerMap字段');
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('module.json5中未找到"name": "entry"');
|
|
|
+ console.log('module.json5中未找到"module"字段');
|
|
|
}
|
|
|
} else {
|
|
|
console.log('module.json5文件不存在');
|
|
|
@@ -199,12 +199,6 @@ function customPlugin(): HvigorPlugin {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
export default {
|
|
|
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
|
plugins: [
|