main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
786 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | /** @typedef {import("./Compiler")} Compiler */
|
---|
| 8 | /** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */
|
---|
| 9 |
|
---|
| 10 | class ContextExclusionPlugin {
|
---|
| 11 | /**
|
---|
| 12 | * @param {RegExp} negativeMatcher Matcher regular expression
|
---|
| 13 | */
|
---|
| 14 | constructor(negativeMatcher) {
|
---|
| 15 | this.negativeMatcher = negativeMatcher;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | /**
|
---|
| 19 | * Apply the plugin
|
---|
| 20 | * @param {Compiler} compiler the compiler instance
|
---|
| 21 | * @returns {void}
|
---|
| 22 | */
|
---|
| 23 | apply(compiler) {
|
---|
| 24 | compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", cmf => {
|
---|
| 25 | cmf.hooks.contextModuleFiles.tap("ContextExclusionPlugin", files =>
|
---|
| 26 | files.filter(filePath => !this.negativeMatcher.test(filePath))
|
---|
| 27 | );
|
---|
| 28 | });
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | module.exports = ContextExclusionPlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.