feat(target): support electron preload async chunk loading

This commit is contained in:
OJ Kwon 2019-05-25 15:52:14 -07:00
parent c1833663cf
commit 2ec75c1cdb
No known key found for this signature in database
GPG Key ID: FFCFEF3460FD1901
3 changed files with 14 additions and 4 deletions

View File

@ -390,7 +390,8 @@ export interface WebpackOptions {
| "async-node"
| "node-webkit"
| "electron-main"
| "electron-renderer")
| "electron-renderer"
| "electron-preload")
| ((compiler: import("../lib/Compiler")) => void);
/**
* Enter watch mode, which rebuilds on file change.

View File

@ -156,11 +156,19 @@ class WebpackOptionsApply extends OptionsApply {
new LoaderTargetPlugin(options.target).apply(compiler);
break;
case "electron-renderer":
JsonpTemplatePlugin = require("./web/JsonpTemplatePlugin");
case "electron-preload":
FetchCompileWasmTemplatePlugin = require("./web/FetchCompileWasmTemplatePlugin");
NodeTargetPlugin = require("./node/NodeTargetPlugin");
ExternalsPlugin = require("./ExternalsPlugin");
new JsonpTemplatePlugin().apply(compiler);
if (options.target === "electron-renderer") {
JsonpTemplatePlugin = require("./web/JsonpTemplatePlugin");
new JsonpTemplatePlugin().apply(compiler);
} else if (options.target === "electron-preload") {
NodeTemplatePlugin = require("./node/NodeTemplatePlugin");
new NodeTemplatePlugin({
asyncChunkLoading: true
}).apply(compiler);
}
new FetchCompileWasmTemplatePlugin({
mangleImports: options.optimization.mangleWasmImports
}).apply(compiler);

View File

@ -2128,7 +2128,8 @@
"async-node",
"node-webkit",
"electron-main",
"electron-renderer"
"electron-renderer",
"electron-preload"
]
},
{