123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- "use strict";
- const EntryDependency = require("./dependencies/EntryDependency");
- class EntryPlugin {
-
- constructor(context, entry, options) {
- this.context = context;
- this.entry = entry;
- this.options = options || "";
- }
-
- apply(compiler) {
- compiler.hooks.compilation.tap(
- "EntryPlugin",
- (compilation, { normalModuleFactory }) => {
- compilation.dependencyFactories.set(
- EntryDependency,
- normalModuleFactory
- );
- }
- );
- const { entry, options, context } = this;
- const dep = EntryPlugin.createDependency(entry, options);
- compiler.hooks.make.tapAsync("EntryPlugin", (compilation, callback) => {
- compilation.addEntry(context, dep, options, err => {
- callback(err);
- });
- });
- }
-
- static createDependency(entry, options) {
- const dep = new EntryDependency(entry);
-
- dep.loc = {
- name:
- typeof options === "object"
- ? (options.name)
- : options
- };
- return dep;
- }
- }
- module.exports = EntryPlugin;
|