Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
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 | /** @typedef {import("../Compiler")} Compiler */
|
---|
9 |
|
---|
10 | class RuntimeChunkPlugin {
|
---|
11 | constructor(options) {
|
---|
12 | this.options = {
|
---|
13 | name: entrypoint => `runtime~${entrypoint.name}`,
|
---|
14 | ...options
|
---|
15 | };
|
---|
16 | }
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Apply the plugin
|
---|
20 | * @param {Compiler} compiler the compiler instance
|
---|
21 | * @returns {void}
|
---|
22 | */
|
---|
23 | apply(compiler) {
|
---|
24 | compiler.hooks.thisCompilation.tap("RuntimeChunkPlugin", compilation => {
|
---|
25 | compilation.hooks.addEntry.tap(
|
---|
26 | "RuntimeChunkPlugin",
|
---|
27 | (_, { name: entryName }) => {
|
---|
28 | if (entryName === undefined) return;
|
---|
29 | const data = compilation.entries.get(entryName);
|
---|
30 | if (data.options.runtime === undefined && !data.options.dependOn) {
|
---|
31 | // Determine runtime chunk name
|
---|
32 | let name = this.options.name;
|
---|
33 | if (typeof name === "function") {
|
---|
34 | name = name({ name: entryName });
|
---|
35 | }
|
---|
36 | data.options.runtime = name;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | );
|
---|
40 | });
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | module.exports = RuntimeChunkPlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.