Skip to content
Permalink
Browse files

fix(plugin-webpack): make the PRELOAD_ENTRY variable map to undefined…

… when there is no preload
  • Loading branch information
MarshallOfSound authored and malept committed Feb 6, 2019
1 parent 1e3cb10 commit 2e71061a7812ccc45d098fd18e555ac71dd7fce3
Showing with 6 additions and 1 deletion.
  1. +6 −1 packages/plugin/webpack/src/WebpackPlugin.ts
@@ -161,11 +161,16 @@ Your packaged app may be larger than expected if you dont ignore everything othe
: `'http://localhost:${BASE_PORT}/${entryPoint.name}/index.js'`;
}

const preloadDefineKey = `${entryPoint.name.toUpperCase().replace(/ /g, '_')}_PRELOAD_WEBPACK_ENTRY`;
if (entryPoint.preload) {
defines[`${entryPoint.name.toUpperCase().replace(/ /g, '_')}_PRELOAD_WEBPACK_ENTRY`] =
defines[preloadDefineKey] =
this.isProd
? `require('path').resolve(__dirname, '../renderer', '${entryPoint.name}', 'preload.js')`
: `'${path.resolve(this.baseDir, 'renderer', entryPoint.name, 'preload.js').replace(/\\/g, '\\\\')}'`;
} else {
// If this entry-point has no configured preload script just map this constant to `undefined`
// so that any code using it still works. This makes quick-start / docs simpler.
defines[preloadDefineKey] = 'undefined';
}
}
return defines;

0 comments on commit 2e71061

Please sign in to comment.
You can’t perform that action at this time.