|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
836 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | "use strict";
|
|---|
| 6 |
|
|---|
| 7 | /** @typedef {import("./Compiler")} Compiler */
|
|---|
| 8 |
|
|---|
| 9 | const PLUGIN_NAME = "ContextExclusionPlugin";
|
|---|
| 10 |
|
|---|
| 11 | class ContextExclusionPlugin {
|
|---|
| 12 | /**
|
|---|
| 13 | * Creates an instance of ContextExclusionPlugin.
|
|---|
| 14 | * @param {RegExp} negativeMatcher Matcher regular expression
|
|---|
| 15 | */
|
|---|
| 16 | constructor(negativeMatcher) {
|
|---|
| 17 | this.negativeMatcher = negativeMatcher;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | /**
|
|---|
| 21 | * Applies the plugin by registering its hooks on the compiler.
|
|---|
| 22 | * @param {Compiler} compiler the compiler instance
|
|---|
| 23 | * @returns {void}
|
|---|
| 24 | */
|
|---|
| 25 | apply(compiler) {
|
|---|
| 26 | compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, (cmf) => {
|
|---|
| 27 | cmf.hooks.contextModuleFiles.tap(PLUGIN_NAME, (files) =>
|
|---|
| 28 | files.filter((filePath) => !this.negativeMatcher.test(filePath))
|
|---|
| 29 | );
|
|---|
| 30 | });
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | module.exports = ContextExclusionPlugin;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.