123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- "use strict";
- class RuntimeChunkPlugin {
-
- constructor(options) {
- this.options = {
-
- name: entrypoint => `runtime~${entrypoint.name}`,
- ...options
- };
- }
-
- apply(compiler) {
- compiler.hooks.thisCompilation.tap("RuntimeChunkPlugin", compilation => {
- compilation.hooks.addEntry.tap(
- "RuntimeChunkPlugin",
- (_, { name: entryName }) => {
- if (entryName === undefined) return;
- const data =
-
- (compilation.entries.get(entryName));
- if (data.options.runtime === undefined && !data.options.dependOn) {
-
- let name =
-
- (this.options.name);
- if (typeof name === "function") {
- name = name({ name: entryName });
- }
- data.options.runtime = name;
- }
- }
- );
- });
- }
- }
- module.exports = RuntimeChunkPlugin;
|