diff --git a/packages/api/core/src/api/package.ts b/packages/api/core/src/api/package.ts index ffcde1c379..6a55b640f0 100644 --- a/packages/api/core/src/api/package.ts +++ b/packages/api/core/src/api/package.ts @@ -192,7 +192,7 @@ export default async ({ } await runHook(forgeConfig, 'generateAssets', platform, arch); - await runHook(forgeConfig, 'prePackage'); + await runHook(forgeConfig, 'prePackage', platform, arch); d('packaging with options', packageOpts); diff --git a/packages/api/core/src/util/index.ts b/packages/api/core/src/util/index.ts index 06b71955b9..31d4629ef0 100644 --- a/packages/api/core/src/util/index.ts +++ b/packages/api/core/src/util/index.ts @@ -1,5 +1,7 @@ import { BuildIdentifierConfig, BuildIdentifierMap, fromBuildIdentifier } from './forge-config'; +import { getElectronVersion } from './electron-version'; import { hasYarn, yarnOrNpmSpawn } from './yarn-or-npm'; +import rebuildHook from './rebuild'; export default class ForgeUtils { /** @@ -13,7 +15,11 @@ export default class ForgeUtils { return fromBuildIdentifier(map); } + getElectronVersion = getElectronVersion; + hasYarn = hasYarn; + rebuildHook = rebuildHook; + yarnOrNpmSpawn = yarnOrNpmSpawn; } diff --git a/packages/plugin/webpack/package.json b/packages/plugin/webpack/package.json index 6d68f91cac..3b75b73aa7 100644 --- a/packages/plugin/webpack/package.json +++ b/packages/plugin/webpack/package.json @@ -24,6 +24,7 @@ }, "dependencies": { "@electron-forge/async-ora": "6.0.0-beta.61", + "@electron-forge/core": "^6.0.0-beta.61", "@electron-forge/plugin-base": "6.0.0-beta.61", "@electron-forge/shared-types": "6.0.0-beta.61", "@electron-forge/web-multi-logger": "6.0.0-beta.61", diff --git a/packages/plugin/webpack/src/WebpackPlugin.ts b/packages/plugin/webpack/src/WebpackPlugin.ts index 3a6f6d1ed2..950a212dc4 100644 --- a/packages/plugin/webpack/src/WebpackPlugin.ts +++ b/packages/plugin/webpack/src/WebpackPlugin.ts @@ -1,15 +1,17 @@ /* eslint "no-console": "off" */ import { asyncOra } from '@electron-forge/async-ora'; import PluginBase from '@electron-forge/plugin-base'; -import { ElectronProcess, ForgeConfig, ForgeHookFn } from '@electron-forge/shared-types'; +import { ElectronProcess, ForgeArch, ForgeConfig, ForgeHookFn, ForgePlatform } from '@electron-forge/shared-types'; import Logger, { Tab } from '@electron-forge/web-multi-logger'; import debug from 'debug'; import fs from 'fs-extra'; import http from 'http'; import { merge } from 'webpack-merge'; import path from 'path'; +import { utils } from '@electron-forge/core'; import webpack, { Configuration, Watching } from 'webpack'; import WebpackDevServer from 'webpack-dev-server'; + import { WebpackPluginConfig } from './Config'; import ElectronForgeLoggingPlugin from './util/ElectronForgeLogging'; import once from './util/once'; @@ -152,8 +154,15 @@ export default class WebpackPlugin extends PluginBase { switch (name) { case 'prePackage': this.isProd = true; - return async () => { + return async (config: ForgeConfig, platform: ForgePlatform, arch: ForgeArch) => { await fs.remove(this.baseDir); + await utils.rebuildHook( + this.projectDir, + await utils.getElectronVersion(this.projectDir, await fs.readJson(path.join(this.projectDir, 'package.json'))), + platform, + arch, + config.electronRebuildConfig + ); await this.compileMain(); await this.compileRenderers(); };