webpack/lib/electron/ElectronTargetPlugin.js

72 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-08-20 05:17:33 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const ExternalsPlugin = require("../ExternalsPlugin");
/** @typedef {import("../Compiler")} Compiler */
class ElectronTargetPlugin {
/**
* @param {boolean} main in main scope?
*/
constructor(main) {
this._main = main;
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
new ExternalsPlugin(
"commonjs",
this._main
? [
"app",
"auto-updater",
"browser-window",
"clipboard",
"content-tracing",
"crash-reporter",
"dialog",
"electron",
"global-shortcut",
"ipc",
"ipc-main",
"menu",
"menu-item",
"native-image",
"original-fs",
"power-monitor",
"power-save-blocker",
"protocol",
"screen",
"session",
"shell",
"tray",
"web-contents"
]
: [
"clipboard",
"crash-reporter",
"desktop-capturer",
"electron",
"ipc",
"ipc-renderer",
"native-image",
"original-fs",
"remote",
"screen",
"shell",
"web-frame"
]
).apply(compiler);
}
}
module.exports = ElectronTargetPlugin;