diff --git a/packages/plugin/webpack/src/WebpackConfig.ts b/packages/plugin/webpack/src/WebpackConfig.ts index f39fc7ca30..0850e2d06c 100644 --- a/packages/plugin/webpack/src/WebpackConfig.ts +++ b/packages/plugin/webpack/src/WebpackConfig.ts @@ -1,3 +1,4 @@ +import debug from 'debug'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import path from 'path'; import webpack, { Configuration } from 'webpack'; @@ -7,6 +8,8 @@ import { WebpackPluginConfig, WebpackPluginEntryPoint, WebpackPreloadEntryPoint type EntryType = string | string[] | Record; +const d = debug('electron-forge:plugin:webpack:webpackconfig'); + export default class WebpackConfigGenerator { private isProd: boolean; @@ -29,6 +32,8 @@ export default class WebpackConfigGenerator { this.webpackDir = path.resolve(projectDir, '.webpack'); this.isProd = isProd; this.port = port; + + d('Config mode:', this.mode); } resolveConfig(config: Configuration | string) { diff --git a/packages/plugin/webpack/src/WebpackPlugin.ts b/packages/plugin/webpack/src/WebpackPlugin.ts index e73b5f61c3..f4744f0b36 100644 --- a/packages/plugin/webpack/src/WebpackPlugin.ts +++ b/packages/plugin/webpack/src/WebpackPlugin.ts @@ -29,7 +29,7 @@ export default class WebpackPlugin extends PluginBase { private baseDir!: string; - private configGenerator!: WebpackConfigGenerator; + private _configGenerator!: WebpackConfigGenerator; private watchers: webpack.Compiler.Watching[] = []; @@ -128,13 +128,22 @@ export default class WebpackPlugin extends PluginBase { setDirectories = (dir: string) => { this.projectDir = dir; this.baseDir = path.resolve(dir, '.webpack'); + } - this.configGenerator = new WebpackConfigGenerator( - this.config, - this.projectDir, - this.isProd, - this.port, - ); + get configGenerator() { + // eslint-disable-next-line no-underscore-dangle + if (!this._configGenerator) { + // eslint-disable-next-line no-underscore-dangle + this._configGenerator = new WebpackConfigGenerator( + this.config, + this.projectDir, + this.isProd, + this.port, + ); + } + + // eslint-disable-next-line no-underscore-dangle + return this._configGenerator; } private loggedOutputUrl = false;