| | |
| | | |
| | | const RawModule = require("./RawModule"); |
| | | const EntryDependency = require("./dependencies/EntryDependency"); |
| | | const createSchemaValidation = require("./util/create-schema-validation"); |
| | | |
| | | /** @typedef {import("../declarations/plugins/IgnorePlugin").IgnorePluginOptions} IgnorePluginOptions */ |
| | | /** @typedef {import("./Compiler")} Compiler */ |
| | | /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */ |
| | | /** @typedef {import("./ContextModuleFactory").BeforeContextResolveData} BeforeContextResolveData */ |
| | | |
| | | const validate = createSchemaValidation( |
| | | require("../schemas/plugins/IgnorePlugin.check"), |
| | | () => require("../schemas/plugins/IgnorePlugin.json"), |
| | | { |
| | | name: "Ignore Plugin", |
| | | baseDataPath: "options" |
| | | } |
| | | ); |
| | | |
| | | /** @typedef {(resource: string, context: string) => boolean} CheckResourceFn */ |
| | | |
| | |
| | | |
| | | class IgnorePlugin { |
| | | /** |
| | | * Creates an instance of IgnorePlugin. |
| | | * @param {IgnorePluginOptions} options IgnorePlugin options |
| | | */ |
| | | constructor(options) { |
| | | validate(options); |
| | | this.options = options; |
| | | this.checkIgnore = this.checkIgnore.bind(this); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | | apply(compiler) { |
| | | compiler.hooks.validate.tap(PLUGIN_NAME, () => { |
| | | compiler.validate( |
| | | require("../schemas/plugins/IgnorePlugin.json"), |
| | | this.options, |
| | | { |
| | | name: "Ignore Plugin", |
| | | baseDataPath: "options" |
| | | }, |
| | | (options) => require("../schemas/plugins/IgnorePlugin.check")(options) |
| | | ); |
| | | }); |
| | | |
| | | compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, (nmf) => { |
| | | nmf.hooks.beforeResolve.tap(PLUGIN_NAME, (resolveData) => { |
| | | const result = this.checkIgnore(resolveData); |