piral-cli-webpack5 0.14.5 → 0.14.6-beta.3419

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/extend-config.js +40 -8
  2. package/package.json +3 -3
package/extend-config.js CHANGED
@@ -2,7 +2,11 @@ function changePlugin(config, classRef, cb) {
2
2
  config.module.plugins = config.module.plugins
3
3
  .map((plugin) => {
4
4
  if (plugin instanceof classRef) {
5
- return cb(plugin);
5
+ if (typeof cb === 'function') {
6
+ return cb(plugin);
7
+ } else {
8
+ return cb;
9
+ }
6
10
  }
7
11
 
8
12
  return plugin;
@@ -17,7 +21,11 @@ function changeRule(config, name, cb) {
17
21
  const uses = rule.use || [];
18
22
 
19
23
  if (uses.some((m) => m && (m === loaderPath || (typeof m === 'object' && m.loader === loaderPath)))) {
20
- return cb(rule);
24
+ if (typeof cb === 'function') {
25
+ return cb(rule);
26
+ } else {
27
+ return cb;
28
+ }
21
29
  }
22
30
 
23
31
  return rule;
@@ -31,9 +39,17 @@ function changeLoader(config, name, cb) {
31
39
  changeRule(config, name, (rule) => {
32
40
  rule.use = rule.use.map((m) => {
33
41
  if (m === loaderPath) {
34
- return cb({ loader: m });
42
+ if (typeof cb === 'function') {
43
+ return cb({ loader: m });
44
+ } else {
45
+ return cb;
46
+ }
35
47
  } else if (m.loader === loaderPath) {
36
- return cb(m);
48
+ if (typeof cb === 'function') {
49
+ return cb(m);
50
+ } else {
51
+ return cb;
52
+ }
37
53
  } else {
38
54
  return m;
39
55
  }
@@ -97,22 +113,38 @@ module.exports = function (override) {
97
113
  );
98
114
  }
99
115
 
100
- if ('rules' in override && Array.isArray(override.rules)) {
101
- config.module.rules.push(...override.rules);
116
+ if ('updateRules' in override && Array.isArray(override.updateRules)) {
117
+ override.updateRules.forEach((def) => {
118
+ if (typeof def.name === 'string' && def.rule) {
119
+ changeRule(config, def.name, def.rule);
120
+ }
121
+ });
102
122
  }
103
123
 
104
124
  if ('removeRules' in override && Array.isArray(override.removeRules)) {
105
125
  override.removeRules.forEach((rule) => changeRule(config, rule, () => undefined));
106
126
  }
107
127
 
108
- if ('plugins' in override && Array.isArray(override.plugins)) {
109
- config.plugins.push(...override.plugins);
128
+ if ('rules' in override && Array.isArray(override.rules)) {
129
+ config.module.rules.push(...override.rules);
130
+ }
131
+
132
+ if ('updatePlugins' in override && Array.isArray(override.updatePlugins)) {
133
+ override.updatePlugins.forEach((def) => {
134
+ if (def.type && def.rule) {
135
+ changePlugin(config, def.type, def.plugin);
136
+ }
137
+ });
110
138
  }
111
139
 
112
140
  if ('removePlugins' in override && Array.isArray(override.removePlugins)) {
113
141
  override.removePlugins.forEach((plugin) => changePlugin(config, plugin, () => undefined));
114
142
  }
115
143
 
144
+ if ('plugins' in override && Array.isArray(override.plugins)) {
145
+ config.plugins.push(...override.plugins);
146
+ }
147
+
116
148
  if ('change' in override && typeof override.change === 'function') {
117
149
  config = override.change(config);
118
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli-webpack5",
3
- "version": "0.14.5",
3
+ "version": "0.14.6-beta.3419",
4
4
  "description": "Provides debug and build capabilities for pilets and Piral instances using Webpack v5.",
5
5
  "keywords": [
6
6
  "piral-cli",
@@ -48,7 +48,7 @@
48
48
  "@types/node": "^13.9.0",
49
49
  "@types/terser-webpack-plugin": "^5.0.0",
50
50
  "@types/yargs": "^15.0.4",
51
- "piral-cli": "^0.14.5",
51
+ "piral-cli": "0.14.6-beta.3419",
52
52
  "strip-ansi": "^3.0.0",
53
53
  "typescript": "^4.0.2"
54
54
  },
@@ -77,5 +77,5 @@
77
77
  "webpack": "^5.1.3",
78
78
  "webpack-inject-plugin": "^1.5.5"
79
79
  },
80
- "gitHead": "d2c53e25895f855fb7be6f7a09afe6ebe8b599e6"
80
+ "gitHead": "7c83ddb2a2b193991fa16153c92b84356d8a30f4"
81
81
  }