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:
1.1 KB
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
---|
9 | /** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
---|
10 |
|
---|
11 | class BasicEffectRulePlugin {
|
---|
12 | /**
|
---|
13 | * @param {string} ruleProperty the rule property
|
---|
14 | * @param {string=} effectType the effect type
|
---|
15 | */
|
---|
16 | constructor(ruleProperty, effectType) {
|
---|
17 | this.ruleProperty = ruleProperty;
|
---|
18 | this.effectType = effectType || ruleProperty;
|
---|
19 | }
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * @param {RuleSetCompiler} ruleSetCompiler the rule set compiler
|
---|
23 | * @returns {void}
|
---|
24 | */
|
---|
25 | apply(ruleSetCompiler) {
|
---|
26 | ruleSetCompiler.hooks.rule.tap(
|
---|
27 | "BasicEffectRulePlugin",
|
---|
28 | (path, rule, unhandledProperties, result, references) => {
|
---|
29 | if (unhandledProperties.has(this.ruleProperty)) {
|
---|
30 | unhandledProperties.delete(this.ruleProperty);
|
---|
31 |
|
---|
32 | const value =
|
---|
33 | rule[/** @type {keyof RuleSetRule} */ (this.ruleProperty)];
|
---|
34 |
|
---|
35 | result.effects.push({
|
---|
36 | type: this.effectType,
|
---|
37 | value
|
---|
38 | });
|
---|
39 | }
|
---|
40 | }
|
---|
41 | );
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | module.exports = BasicEffectRulePlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.