跳到内容

app builder lib.Interface.Hooks

Electron-Builder / app-builder-lib / Hooks

扩展自

属性

afterAllArtifactBuild?

readonly optional afterAllArtifactBuild: null | string | Hook<BuildResult, string[]>

在所有构件构建完成后要运行的函数(或文件路径或模块 ID)。

(buildResult: BuildResult): Promise<Array<string>> | Array<string>

配置方式与 afterPack 相同(见上文)。

myAfterAllArtifactBuild.js

exports.default = function () {
  // you can return additional files to publish
  return ["/path/to/additional/result/file"]
}

afterExtract?

readonly optional afterExtract: null | string | Hook<PackContext, void>

预构建的 Electron 二进制文件被提取到输出目录后要运行的函数(或文件路径或模块 ID)。设置方式与 beforePack 相同


afterPack?

readonly optional afterPack: null | string | Hook<PackContext, void>

打包后(但在打包成可分发格式和签名之前)要运行的函数(或文件路径或模块 ID)。设置方式与 beforePack 相同


afterSign?

readonly optional afterSign: null | string | Hook<PackContext, void>

打包和签名后(但在打包成可分发格式之前)要运行的函数(或文件路径或模块 ID)。设置方式与 beforePack 相同


appxManifestCreated?

readonly optional appxManifestCreated: null | string | Hook<string, void>

在 Appx 清单文件创建到磁盘后(尚未打包到 .appx 包中)要运行的函数(或文件路径或模块 ID)。


artifactBuildCompleted?

readonly optional artifactBuildCompleted: null | string | Hook<ArtifactCreated, void>

在构件构建完成后要运行的函数(或文件路径或模块 ID)。设置方式与 beforePack 相同


artifactBuildStarted?

readonly optional artifactBuildStarted: null | string | Hook<ArtifactBuildStarted, void>

在构件构建开始时要运行的函数(或文件路径或模块 ID)。设置方式与 beforePack 相同


beforeBuild?

readonly optional beforeBuild: null | string | Hook<BeforeBuildContext, boolean | void>

在安装或重新构建依赖项之前要运行的函数(或文件路径或模块 ID)。当 npmRebuild 设置为 true 时工作。解析为 false 将跳过依赖项安装或重新构建。

如果提供且 node_modules 缺失,则不会调用生产依赖项检查。


beforePack?

readonly optional beforePack: null | string | Hook<PackContext, void>

在打包之前要运行的函数(或文件路径或模块 ID)。

(context: BeforePackContext): Promise<any> | any

作为函数

beforePack: async (context) => {
  // your code
}

因为在配置文件中无法使用 JavaScript,所以可以指定为文件路径或模块 ID。函数必须作为默认导出导出。

"build": {
  "beforePack": "./myBeforePackHook.js"
}

项目根目录中的文件 myBeforePackHook.js

myBeforePackHook.js

exports.default = async function(context) {
  // your custom code
}

electronDist?

readonly optional electronDist: null | string | Hook<PrepareApplicationStageDirectoryOptions, string>

在暂存 electron 构件环境时要运行的函数(或文件路径或模块 ID)。返回自定义 Electron 构建(例如 ~/electron/out/R)或 electron zip 文件目录的路径。

Zip 文件必须遵循 electron-v${version}-${platformName}-${arch}.zip 模式,否则将被假定为未打包的 Electron 应用程序目录


msiProjectCreated?

readonly optional msiProjectCreated: null | string | Hook<string, void>

在 MSI 项目创建到磁盘后(尚未打包到 .msi 包中)要运行的函数(或文件路径或模块 ID)。


onNodeModuleFile?

readonly optional onNodeModuleFile: null | string | Hook<string, boolean | void>

每个 node module 文件上运行的函数(或文件路径或模块 ID)。返回 true/false 将确定是否强制包含或使用默认的复制器逻辑