Skip to content

Introduction

electron-egg supports packaging your application for HarmonyOS (OpenHarmony). The Electron build artifacts are extracted and copied into a HarmonyOS HAP resource directory, where the HAP project's web engine loads them.

This is handled by the ohos command in ee-bin, which follows electron-builder's extraResources FileSet pattern (from / to / filter) for flexible resource selection.

Configuration

Declare the resources to extract under the ohos key in your bin.js config. Each entry is a FileSet:

javascript
// config/bin.js (or bin.json)
module.exports = {
  // ...other ee-bin config
  ohos: {
    resources: [
      {
        from: 'out/extraResources',
        to: 'ohos_hap/web_engine/resources',
        filter: ['**/*', '!compiled'] // copy everything except the compiled dir
      }
    ]
  }
}
FieldTypeDescription
fromstringSource path (relative to project root) of the build artifacts to copy
tostringDestination path (relative to project root) inside the HAP resource directory
filterstring[]Glob patterns. **/* matches all; !pattern excludes. Defaults to ['**/*']

Usage

Run the ohos-resources npm script (defined in package.json):

bash
npm run ohos-resources

Which executes:

bash
ee-bin ohos --cmds=resources

--cmds accepts a comma-separated list of keys under ohos to process. If omitted, all array-type properties under ohos are processed.