如何快速关闭工程中所有字节码HAR配置
===================

**解决措施**

方案一：适用于HAR文件较少的场景，直接修改字段byteCodeHar为false，详细字段可在以下链接中查询：[模块级build-profile.json5](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-hvigor-build-profile)

方案二：适用于HAR文件数量较多的场景。单独为每个HAR包配置较为繁琐，可以通过自定义插件直接修改所有HAR包的byteCodeHar字段值。该方法在编译时生效，但不会修改build-profile.json5文件中的字段值。

_// Engineering-level hvigorfile.ts file_
import { hvigor, HvigorNode, HvigorPlugin } from '@ohos/hvigor';
import { appTasks, OhosHarContext, OhosPluginId, Target } from '@ohos/hvigor-ohos-plugin';
_// Implement custom plugins_
export function customPlugin(): HvigorPlugin {
  return {
    pluginId: 'customPlugin',
    async apply(currentNode: HvigorNode): Promise<void> {
      hvigor.afterNodeEvaluate(async () => {
        _// Register module-level tasks_
        harTask(currentNode);
      });
    }
  };
}
function harTask(currentNode: HvigorNode) {
  currentNode.subNodes((node: HvigorNode) => {
    const context = node.getContext(OhosPluginId.OHOS\_HAR\_PLUGIN)
    context?.targets((target: Target) => {
      const targetName = target.getTargetName();
      node.registerTask({
        _// Task name_
        name: \`HarTask\`,
        _// Main function of task execution logic_
        run() {
          if (context.getBuildProfileOpt) {
            const buildProfile = context.getBuildProfileOpt();
            console.log(buildProfile)
            _// Set the bytecode har config to false_
            buildProfile\["buildOption"\] = { arkOptions: { byteCodeHar: false } };
            console.log(buildProfile)
            context.setBuildProfileOpt(buildProfile);
          }
        },
        _// Configure the dependency of the pre-task_
        dependencies: \[\`${targetName}@PackageHar\`\],
        _// Post-task dependency for configuring tasks_
        postDependencies: \['assembleHar'\]
      });
    });
  });
}
export default {
  system: appTasks,  _/\* Built-in plugin of Hvigor. It cannot be modified. \*/_
  plugins:\[customPlugin()\]  _/\* Custom plugin to extend the functionality of Hvigor. \*/_
}