Skip to content

Commit

Permalink
fix(plugin-webpack): make the PRELOAD_ENTRY variable map to undefined…
Browse files Browse the repository at this point in the history
… when there is no preload
  • Loading branch information
MarshallOfSound authored and malept committed Feb 6, 2019
1 parent 1e3cb10 commit 2e71061
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/plugin/webpack/src/WebpackPlugin.ts
Expand Up @@ -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;
Expand Down

0 comments on commit 2e71061

Please sign in to comment.