Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
899 bytes
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
---|
9 |
|
---|
10 | /** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
---|
11 | /** @typedef {import("./Compiler")} Compiler */
|
---|
12 |
|
---|
13 | class ExternalsPlugin {
|
---|
14 | /**
|
---|
15 | * @param {string | undefined} type default external type
|
---|
16 | * @param {Externals} externals externals config
|
---|
17 | */
|
---|
18 | constructor(type, externals) {
|
---|
19 | this.type = type;
|
---|
20 | this.externals = externals;
|
---|
21 | }
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Apply the plugin
|
---|
25 | * @param {Compiler} compiler the compiler instance
|
---|
26 | * @returns {void}
|
---|
27 | */
|
---|
28 | apply(compiler) {
|
---|
29 | compiler.hooks.compile.tap("ExternalsPlugin", ({ normalModuleFactory }) => {
|
---|
30 | new ExternalModuleFactoryPlugin(this.type, this.externals).apply(
|
---|
31 | normalModuleFactory
|
---|
32 | );
|
---|
33 | });
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | module.exports = ExternalsPlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.