weboptimizer 2.0.1492 → 2.0.1494
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.
- package/ejsLoader.js +1 -1
- package/eslint.config.mjs +1 -0
- package/jestSetup.js +1 -3
- package/package.json +11 -11
- package/plugins/InPlaceAssetsIntoHTML.js +1 -1
- package/type.d.ts +7 -7
- package/webpackConfigurator.js +70 -62
package/ejsLoader.js
CHANGED
|
@@ -67,7 +67,7 @@ var loader = exports.loader = function loader(source) {
|
|
|
67
67
|
aliases: {},
|
|
68
68
|
replacements: {}
|
|
69
69
|
}
|
|
70
|
-
}, this.getOptions()), /#%%%#/g, '!');
|
|
70
|
+
}, Object.prototype.hasOwnProperty.call(this, 'getOptions') ? this.getOptions() : {}), /#%%%#/g, '!');
|
|
71
71
|
var _compile = function compile(template) {
|
|
72
72
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : givenOptions.compiler;
|
|
73
73
|
var compileSteps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
package/eslint.config.mjs
CHANGED
|
@@ -95,6 +95,7 @@ export const config = tseslint.config({
|
|
|
95
95
|
// NOTE: Too strcit for now but could be actvated in future maybe.
|
|
96
96
|
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
97
97
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
98
|
+
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
|
|
98
99
|
'jsdoc/check-param-names': 'error',
|
|
99
100
|
'jsdoc/check-tag-names': 'error',
|
|
100
101
|
'jsdoc/require-description-complete-sentence': 'error',
|
package/jestSetup.js
CHANGED
|
@@ -22,8 +22,6 @@ _clientnode.globalContext.TextEncoder = _util.TextEncoder;
|
|
|
22
22
|
_clientnode.globalContext.TextDecoder = _util.TextDecoder;
|
|
23
23
|
try {
|
|
24
24
|
if (eval('require')('jest-canvas-mock')) console.info('Canvas mocking module loaded.');
|
|
25
|
-
|
|
26
|
-
} catch (error) {
|
|
27
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
25
|
+
} catch (_error) {
|
|
28
26
|
// Do nothing.
|
|
29
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1494",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"babel-loader": "^9.1.3",
|
|
101
101
|
"babel-plugin-transform-modern-regexp": "^0.0.6",
|
|
102
102
|
"babel-preset-minify": "^0.5.2",
|
|
103
|
-
"clientnode": "3.0.
|
|
103
|
+
"clientnode": "3.0.1170",
|
|
104
104
|
"ejs": "^3.1.10",
|
|
105
105
|
"exports-loader": "^5.0.0",
|
|
106
106
|
"extract-loader": "^5.1.0",
|
|
@@ -120,24 +120,24 @@
|
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@babel/cli": "^7.24.8",
|
|
122
122
|
"@babel/eslint-parser": "^7.25.1",
|
|
123
|
-
"@stylistic/eslint-plugin": "^2.6.
|
|
123
|
+
"@stylistic/eslint-plugin": "^2.6.4",
|
|
124
124
|
"@types/ejs": "^3.1.5",
|
|
125
125
|
"@types/eslint": "^9.6.0",
|
|
126
126
|
"@types/html-minifier": "^4.0.5",
|
|
127
127
|
"@types/html-minifier-terser": "^7.0.2",
|
|
128
128
|
"@types/imagemin": "^9.0.0",
|
|
129
|
-
"@types/node": "^22.1
|
|
129
|
+
"@types/node": "^22.4.1",
|
|
130
130
|
"@types/postcss-import": "^14.0.3",
|
|
131
131
|
"@types/postcss-url": "^10.0.4",
|
|
132
132
|
"@types/webpack-env": "^1.18.5",
|
|
133
133
|
"@types/webpack-sources": "^3.2.3",
|
|
134
|
-
"@typescript-eslint/parser": "^8.0
|
|
134
|
+
"@typescript-eslint/parser": "^8.1.0",
|
|
135
135
|
"css-loader": "^7.1.2",
|
|
136
|
-
"cssnano": "^7.0.
|
|
136
|
+
"cssnano": "^7.0.5",
|
|
137
137
|
"documentation-website": "^1.0.330",
|
|
138
|
-
"eslint": "^9.
|
|
138
|
+
"eslint": "^9.9.0",
|
|
139
139
|
"eslint-config-google": "^0.14.0",
|
|
140
|
-
"eslint-plugin-jsdoc": "^50.
|
|
140
|
+
"eslint-plugin-jsdoc": "^50.2.2",
|
|
141
141
|
"favicons": "^7.2.0",
|
|
142
142
|
"favicons-webpack-plugin": "^6.0.1",
|
|
143
143
|
"globals": "^15.9.0",
|
|
@@ -151,15 +151,15 @@
|
|
|
151
151
|
"postcss-fontpath": "^1.0.0",
|
|
152
152
|
"postcss-import": "^16.1.0",
|
|
153
153
|
"postcss-loader": "^8.1.1",
|
|
154
|
-
"postcss-preset-env": "^10.0.
|
|
154
|
+
"postcss-preset-env": "^10.0.2",
|
|
155
155
|
"postcss-sprites": "^4.2.1",
|
|
156
156
|
"postcss-url": "^10.1.3",
|
|
157
157
|
"shx": "^0.3.4",
|
|
158
158
|
"style-loader": "^4.0.0",
|
|
159
|
-
"stylelint": "^16.8.
|
|
159
|
+
"stylelint": "^16.8.2",
|
|
160
160
|
"stylelint-config-standard": "^36.0.1",
|
|
161
161
|
"stylelint-config-standard-scss": "^13.1.0",
|
|
162
|
-
"typescript-eslint": "^8.0
|
|
162
|
+
"typescript-eslint": "^8.1.0",
|
|
163
163
|
"typescript-plugin-css-modules": "^5.1.0",
|
|
164
164
|
"workbox-webpack-plugin": "^7.1.0"
|
|
165
165
|
},
|
|
@@ -45,7 +45,7 @@ var InPlaceAssetsIntoHTML = exports.InPlaceAssetsIntoHTML = /*#__PURE__*/functio
|
|
|
45
45
|
var inPlacedAssetNames = [];
|
|
46
46
|
hooks.alterAssetTagGroups.tap('inPlaceHTMLAssets', function (assets) {
|
|
47
47
|
var inPlace = function inPlace(type, tag) {
|
|
48
|
-
var settings;
|
|
48
|
+
var settings = null;
|
|
49
49
|
var url = false;
|
|
50
50
|
if (tag.tagName === 'script') {
|
|
51
51
|
settings = _this.options.javaScript;
|
package/type.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface RedundantRequest {
|
|
|
40
40
|
path: string;
|
|
41
41
|
version: string;
|
|
42
42
|
}
|
|
43
|
-
export type ExternalAliases = Mapping<Mapping | string | ((_request: string, _key: string) => string)>;
|
|
43
|
+
export type ExternalAliases = Mapping<Mapping | null | string | ((_request: string, _key: string) => string)>;
|
|
44
44
|
export type GivenInjection = AnyFunction | string | Array<string> | Mapping<string | Array<string>>;
|
|
45
45
|
export type NormalizedGivenInjection = Mapping<Array<string>>;
|
|
46
46
|
export interface GivenInjectionConfiguration {
|
|
@@ -83,8 +83,8 @@ export interface HTMLTransformationOptions {
|
|
|
83
83
|
files: Array<HTMLConfiguration>;
|
|
84
84
|
}
|
|
85
85
|
export interface InPlaceAssetsIntoHTMLOptions {
|
|
86
|
-
cascadingStyleSheet: InPlaceAssetConfiguration;
|
|
87
|
-
javaScript: InPlaceAssetConfiguration;
|
|
86
|
+
cascadingStyleSheet: InPlaceAssetConfiguration | null;
|
|
87
|
+
javaScript: InPlaceAssetConfiguration | null;
|
|
88
88
|
htmlPlugin: typeof HtmlWebpackPlugin;
|
|
89
89
|
}
|
|
90
90
|
export interface AssetPathConfiguration {
|
|
@@ -241,12 +241,12 @@ export interface InPlaceAssetConfiguration {
|
|
|
241
241
|
head?: Array<RegExp | string> | RegExp | string;
|
|
242
242
|
}
|
|
243
243
|
export interface InPlaceConfiguration {
|
|
244
|
-
cascadingStyleSheet: InPlaceAssetConfiguration;
|
|
244
|
+
cascadingStyleSheet: InPlaceAssetConfiguration | null;
|
|
245
245
|
externalLibrary: {
|
|
246
246
|
normal: boolean;
|
|
247
247
|
dynamic: boolean;
|
|
248
248
|
};
|
|
249
|
-
javaScript: InPlaceAssetConfiguration;
|
|
249
|
+
javaScript: InPlaceAssetConfiguration | null;
|
|
250
250
|
otherMaximumFileSizeLimitInByte: number;
|
|
251
251
|
}
|
|
252
252
|
export interface ResolvedConfiguration {
|
|
@@ -329,7 +329,7 @@ export interface ResolvedConfiguration {
|
|
|
329
329
|
};
|
|
330
330
|
module?: PlainObject;
|
|
331
331
|
};
|
|
332
|
-
cssnano
|
|
332
|
+
cssnano?: PlainObject;
|
|
333
333
|
data: ResourceLoaderConfiguration;
|
|
334
334
|
font: {
|
|
335
335
|
eot: ResourceLoaderConfiguration;
|
|
@@ -340,7 +340,7 @@ export interface ResolvedConfiguration {
|
|
|
340
340
|
htmlMinifier?: PlainObject;
|
|
341
341
|
image: {
|
|
342
342
|
content: ImageMinimizerOptions<unknown, unknown>;
|
|
343
|
-
exclude: string;
|
|
343
|
+
exclude: null | string;
|
|
344
344
|
loader: Array<string>;
|
|
345
345
|
};
|
|
346
346
|
};
|
package/webpackConfigurator.js
CHANGED
|
@@ -23,8 +23,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
23
23
|
exports.webpackConfiguration = exports.optionalRequire = exports["default"] = void 0;
|
|
24
24
|
var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
|
|
25
25
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
26
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
27
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
28
28
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
29
29
|
var _clientnode = require("clientnode");
|
|
30
30
|
var _path = require("path");
|
|
@@ -35,7 +35,7 @@ var _configurator = _interopRequireDefault(require("./configurator"));
|
|
|
35
35
|
var _helper = require("./helper");
|
|
36
36
|
var _InPlaceAssetsIntoHTML = _interopRequireDefault(require("./plugins/InPlaceAssetsIntoHTML"));
|
|
37
37
|
var _HTMLTransformation = _interopRequireDefault(require("./plugins/HTMLTransformation"));
|
|
38
|
-
var _optionalRequire, _configuration$
|
|
38
|
+
var _optionalRequire, _configuration$cache$, _configuration$cache, _configuration$cache2, _configuration$cache3;
|
|
39
39
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
40
40
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
41
41
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -52,9 +52,7 @@ eval("typeof require === 'undefined' ? null : require");
|
|
|
52
52
|
var optionalRequire = exports.optionalRequire = function optionalRequire(id) {
|
|
53
53
|
try {
|
|
54
54
|
return currentRequire ? currentRequire(id) : null;
|
|
55
|
-
|
|
56
|
-
} catch (error) {
|
|
57
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
55
|
+
} catch (_error) {
|
|
58
56
|
return null;
|
|
59
57
|
}
|
|
60
58
|
};
|
|
@@ -133,29 +131,31 @@ for (var _i2 = 0, _Object$entries2 = Object.entries(_module.replacements.normal)
|
|
|
133
131
|
//// endregion
|
|
134
132
|
//// region generate html file
|
|
135
133
|
var htmlAvailable = false;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
if (plugins.HTML) {
|
|
135
|
+
var _iterator2 = _createForOfIteratorHelper(configuration.files.html),
|
|
136
|
+
_step2;
|
|
137
|
+
try {
|
|
138
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
139
|
+
var htmlConfiguration = _step2.value;
|
|
140
|
+
if ((0, _clientnode.isFileSync)(htmlConfiguration.template.filePath)) {
|
|
141
|
+
pluginInstances.push(new plugins.HTML(_objectSpread(_objectSpread({}, htmlConfiguration), {}, {
|
|
142
|
+
template: htmlConfiguration.template.request
|
|
143
|
+
})));
|
|
144
|
+
htmlAvailable = true;
|
|
145
|
+
}
|
|
146
146
|
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
_iterator2.e(err);
|
|
149
|
+
} finally {
|
|
150
|
+
_iterator2.f();
|
|
147
151
|
}
|
|
148
|
-
//// endregion
|
|
149
|
-
//// region generate favicons
|
|
150
|
-
} catch (err) {
|
|
151
|
-
_iterator2.e(err);
|
|
152
|
-
} finally {
|
|
153
|
-
_iterator2.f();
|
|
154
152
|
}
|
|
155
|
-
|
|
153
|
+
//// endregion
|
|
154
|
+
//// region generate favicons
|
|
155
|
+
if (htmlAvailable && Object.prototype.hasOwnProperty.call(configuration, 'favicon') && plugins.Favicon && (0, _clientnode.isFileSync)([].concat(configuration.favicon.logo)[0])) pluginInstances.push(new plugins.Favicon(configuration.favicon));
|
|
156
156
|
//// endregion
|
|
157
157
|
//// region provide offline functionality
|
|
158
|
-
if (htmlAvailable && configuration
|
|
158
|
+
if (htmlAvailable && Object.prototype.hasOwnProperty.call(configuration, 'offline') && Object.prototype.hasOwnProperty.call(plugins, 'Offline')) {
|
|
159
159
|
if (!['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) for (var _i3 = 0, _Object$entries3 = Object.entries({
|
|
160
160
|
cascadingStyleSheet: 'css',
|
|
161
161
|
javaScript: 'js'
|
|
@@ -173,12 +173,12 @@ if (htmlAvailable && configuration.offline && plugins.Offline) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
if ([].concat(configuration.offline.use).includes('injectionManifest')) pluginInstances.push(new plugins.InjectManifest((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.injectionManifest)));
|
|
177
|
-
if ([].concat(configuration.offline.use).includes('generateServiceWorker')) pluginInstances.push(new plugins.GenerateServiceWorker((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.serviceWorker)));
|
|
176
|
+
if (plugins.InjectManifest && [].concat(configuration.offline.use).includes('injectionManifest')) pluginInstances.push(new plugins.InjectManifest((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.injectionManifest)));
|
|
177
|
+
if (plugins.GenerateServiceWorker && [].concat(configuration.offline.use).includes('generateServiceWorker')) pluginInstances.push(new plugins.GenerateServiceWorker((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.serviceWorker)));
|
|
178
178
|
}
|
|
179
179
|
//// endregion
|
|
180
180
|
//// region provide build environment
|
|
181
|
-
if (configuration.buildContext
|
|
181
|
+
if (Object.prototype.hasOwnProperty.call(configuration.buildContext, 'definitions')) pluginInstances.push(new _webpack.DefinePlugin(configuration.buildContext.definitions));
|
|
182
182
|
if (_module.provide) pluginInstances.push(new _webpack.ProvidePlugin(_module.provide));
|
|
183
183
|
//// endregion
|
|
184
184
|
//// region modules/assets
|
|
@@ -198,7 +198,7 @@ pluginInstances.push({
|
|
|
198
198
|
asset = _Object$entries4$_i[1];
|
|
199
199
|
var filePath = request.replace(/\?[^?]+$/, '');
|
|
200
200
|
var _type = (0, _helper.determineAssetType)(filePath, configuration.buildContext.types, configuration.path);
|
|
201
|
-
if (_type && configuration.assetPattern
|
|
201
|
+
if (_type && Object.prototype.hasOwnProperty.call(configuration.assetPattern, _type) && new RegExp(configuration.assetPattern[_type].includeFilePathRegularExpression).test(filePath) && !new RegExp(configuration.assetPattern[_type].excludeFilePathRegularExpression).test(filePath)) {
|
|
202
202
|
var source = asset.source();
|
|
203
203
|
if (typeof source === 'string') compilation.assets[request] = new _webpackSources.RawSource(configuration.assetPattern[_type].pattern.replace(/\{1\}/g, source.replace(/\$/g, '$$$')));
|
|
204
204
|
}
|
|
@@ -229,7 +229,7 @@ pluginInstances.push({
|
|
|
229
229
|
.replace(/##-#-#-##/g, '%>')
|
|
230
230
|
*/
|
|
231
231
|
|
|
232
|
-
if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2]) && configuration.inPlace.cascadingStyleSheet && Object.keys(configuration.inPlace.cascadingStyleSheet).length || configuration.inPlace.javaScript && Object.keys(configuration.inPlace.javaScript).length) pluginInstances.push(new _InPlaceAssetsIntoHTML["default"]({
|
|
232
|
+
if (plugins.HTML && htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2]) && configuration.inPlace.cascadingStyleSheet && Object.keys(configuration.inPlace.cascadingStyleSheet).length || configuration.inPlace.javaScript && Object.keys(configuration.inPlace.javaScript).length) pluginInstances.push(new _InPlaceAssetsIntoHTML["default"]({
|
|
233
233
|
cascadingStyleSheet: configuration.inPlace.cascadingStyleSheet,
|
|
234
234
|
javaScript: configuration.inPlace.javaScript,
|
|
235
235
|
htmlPlugin: plugins.HTML
|
|
@@ -256,7 +256,10 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
256
256
|
configuration.injection.external.modules = function (_ref, callback) {
|
|
257
257
|
var context = _ref.context,
|
|
258
258
|
request = _ref.request;
|
|
259
|
-
if (typeof request !== 'string')
|
|
259
|
+
if (typeof request !== 'string') {
|
|
260
|
+
callback();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
260
263
|
request = request.replace(/^!+/, '');
|
|
261
264
|
if (request.startsWith('/')) request = (0, _path.relative)(configuration.path.context, request);
|
|
262
265
|
var _iterator3 = _createForOfIteratorHelper(_module.directoryNames),
|
|
@@ -283,7 +286,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
283
286
|
var _Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i6], 2),
|
|
284
287
|
pattern = _Object$entries5$_i[0],
|
|
285
288
|
targetConfiguration = _Object$entries5$_i[1];
|
|
286
|
-
if (pattern.startsWith('^')) {
|
|
289
|
+
if (targetConfiguration && pattern.startsWith('^')) {
|
|
287
290
|
var regularExpression = new RegExp(pattern);
|
|
288
291
|
if (regularExpression.test(filePath)) {
|
|
289
292
|
var match = false;
|
|
@@ -358,18 +361,19 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
358
361
|
}
|
|
359
362
|
// endregion
|
|
360
363
|
}
|
|
361
|
-
if (typeof result !== 'string' && Object.prototype.hasOwnProperty.call(result, 'root')) result.root = [].concat(result.root).map(function (name) {
|
|
364
|
+
if (typeof result !== 'string' && Object.prototype.hasOwnProperty.call(result, 'root') && Array.isArray(result.root)) result.root = [].concat(result.root).map(function (name) {
|
|
362
365
|
return (0, _clientnode.convertToValidVariableName)(name);
|
|
363
366
|
});
|
|
364
|
-
var exportFormat = configuration.exportFormat.external
|
|
365
|
-
|
|
367
|
+
var exportFormat = Object.prototype.hasOwnProperty.call(configuration.exportFormat, 'external') ? configuration.exportFormat.external : configuration.exportFormat.self;
|
|
368
|
+
callback(undefined, exportFormat === 'umd' || typeof result === 'string' ? result : result[exportFormat], exportFormat);
|
|
369
|
+
return;
|
|
366
370
|
}
|
|
367
|
-
|
|
371
|
+
callback();
|
|
368
372
|
};
|
|
369
373
|
///// endregion
|
|
370
374
|
//// endregion
|
|
371
375
|
//// region apply final html modifications/fixes
|
|
372
|
-
if (htmlAvailable) pluginInstances.push(new _HTMLTransformation["default"]({
|
|
376
|
+
if (htmlAvailable && plugins.HTML) pluginInstances.push(new _HTMLTransformation["default"]({
|
|
373
377
|
hashAlgorithm: configuration.hashAlgorithm,
|
|
374
378
|
htmlPlugin: plugins.HTML,
|
|
375
379
|
files: configuration.files.html
|
|
@@ -484,8 +488,8 @@ if (_module.enforceDeduplication) {
|
|
|
484
488
|
};
|
|
485
489
|
pluginInstances.push({
|
|
486
490
|
apply: function apply(compiler) {
|
|
487
|
-
|
|
488
|
-
|
|
491
|
+
compiler.hooks.normalModuleFactory.tap('WebOptimizerModuleConsolidation', function (nmf) {
|
|
492
|
+
nmf.hooks.afterResolve.tap('WebOptimizerModuleConsolidation', consolidator);
|
|
489
493
|
});
|
|
490
494
|
}
|
|
491
495
|
});
|
|
@@ -588,7 +592,7 @@ var scope = {
|
|
|
588
592
|
configuration: configuration,
|
|
589
593
|
isFilePathInDependencies: isFilePathInDependencies,
|
|
590
594
|
loader: loader,
|
|
591
|
-
require: currentRequire
|
|
595
|
+
require: currentRequire !== null && currentRequire !== void 0 ? currentRequire : require
|
|
592
596
|
};
|
|
593
597
|
var evaluateAnThrow = function evaluateAnThrow(object) {
|
|
594
598
|
var filePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : configuration.path.context;
|
|
@@ -607,7 +611,7 @@ var evaluateMapper = function evaluateMapper(value) {
|
|
|
607
611
|
var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderConfiguration(loaderConfiguration) {
|
|
608
612
|
return {
|
|
609
613
|
exclude: function exclude(filePath) {
|
|
610
|
-
return
|
|
614
|
+
return evaluateAnThrow(loaderConfiguration.exclude, filePath);
|
|
611
615
|
},
|
|
612
616
|
include: loaderConfiguration.include && evaluateAnThrow(loaderConfiguration.include) || configuration.path.source.base,
|
|
613
617
|
test: new RegExp(evaluateAnThrow(loaderConfiguration.test)),
|
|
@@ -655,7 +659,7 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
655
659
|
}) : [], postcssSprites ? postcssSprites({
|
|
656
660
|
filterBy: function filterBy() {
|
|
657
661
|
return new Promise(function (resolve, reject) {
|
|
658
|
-
|
|
662
|
+
(configuration.files.compose.image ? resolve : reject)();
|
|
659
663
|
});
|
|
660
664
|
},
|
|
661
665
|
hooks: {
|
|
@@ -670,9 +674,9 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
670
674
|
(e.g. linear gradient instead).
|
|
671
675
|
*/
|
|
672
676
|
onUpdateRule: function onUpdateRule(rule, token, image) {
|
|
673
|
-
if (token.value.includes(token.text)) updateRule(rule, token, image);else token.cloneAfter({
|
|
677
|
+
if (updateRule) if (token.value.includes(token.text)) updateRule(rule, token, image);else token.cloneAfter({
|
|
674
678
|
type: 'decl',
|
|
675
|
-
prop: 'background-image',
|
|
679
|
+
prop: 'background-' + 'image',
|
|
676
680
|
value: token.value
|
|
677
681
|
});
|
|
678
682
|
}
|
|
@@ -690,7 +694,7 @@ var genericLoader = {
|
|
|
690
694
|
exclude: function exclude(filePath) {
|
|
691
695
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
692
696
|
return htmlConfiguration.template.filePath;
|
|
693
|
-
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false :
|
|
697
|
+
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false : evaluateAnThrow(_module.preprocessor.ejs.exclude, filePath);
|
|
694
698
|
},
|
|
695
699
|
include: getIncludingPaths(configuration.path.source.asset.template),
|
|
696
700
|
test: /^(?!.+\.html\.ejs$).+\.ejs$/i,
|
|
@@ -709,7 +713,7 @@ var genericLoader = {
|
|
|
709
713
|
// region script
|
|
710
714
|
script: {
|
|
711
715
|
exclude: function exclude(filePath) {
|
|
712
|
-
return
|
|
716
|
+
return evaluateAnThrow(_module.preprocessor.javaScript.exclude, filePath);
|
|
713
717
|
},
|
|
714
718
|
include: function include(filePath) {
|
|
715
719
|
var result = evaluateAnThrow(_module.preprocessor.javaScript.include, filePath);
|
|
@@ -748,7 +752,7 @@ var genericLoader = {
|
|
|
748
752
|
exclude: function exclude(filePath) {
|
|
749
753
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
750
754
|
return htmlConfiguration.template.filePath;
|
|
751
|
-
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false :
|
|
755
|
+
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : evaluateAnThrow(_module.preprocessor.html.exclude, filePath));
|
|
752
756
|
},
|
|
753
757
|
include: configuration.path.source.asset.template,
|
|
754
758
|
test: /\.html\.ejs(?:\?.*)?$/i,
|
|
@@ -772,7 +776,7 @@ var genericLoader = {
|
|
|
772
776
|
exclude: function exclude(filePath) {
|
|
773
777
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
774
778
|
return htmlConfiguration.template.filePath;
|
|
775
|
-
})).includes(filePath) || (_module.html.exclude === null ? true :
|
|
779
|
+
})).includes(filePath) || (_module.html.exclude === null ? true : evaluateAnThrow(_module.html.exclude, filePath));
|
|
776
780
|
},
|
|
777
781
|
include: configuration.path.source.asset.template,
|
|
778
782
|
test: /\.html(?:\?.*)?$/i,
|
|
@@ -791,7 +795,7 @@ var genericLoader = {
|
|
|
791
795
|
// region style
|
|
792
796
|
style: {
|
|
793
797
|
exclude: function exclude(filePath) {
|
|
794
|
-
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) :
|
|
798
|
+
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.cascadingStyleSheet.exclude, filePath);
|
|
795
799
|
},
|
|
796
800
|
include: function include(filePath) {
|
|
797
801
|
var result = evaluateAnThrow(_module.cascadingStyleSheet.include, filePath);
|
|
@@ -821,7 +825,7 @@ var genericLoader = {
|
|
|
821
825
|
font: {
|
|
822
826
|
eot: {
|
|
823
827
|
exclude: function exclude(filePath) {
|
|
824
|
-
return _module.optimizer.font.eot.exclude === null ? false :
|
|
828
|
+
return _module.optimizer.font.eot.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.eot.exclude, filePath);
|
|
825
829
|
},
|
|
826
830
|
generator: {
|
|
827
831
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -837,7 +841,7 @@ var genericLoader = {
|
|
|
837
841
|
},
|
|
838
842
|
svg: {
|
|
839
843
|
exclude: function exclude(filePath) {
|
|
840
|
-
return _module.optimizer.font.svg.exclude === null ? false :
|
|
844
|
+
return _module.optimizer.font.svg.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.svg.exclude, filePath);
|
|
841
845
|
},
|
|
842
846
|
include: configuration.path.source.asset.font,
|
|
843
847
|
generator: {
|
|
@@ -855,7 +859,7 @@ var genericLoader = {
|
|
|
855
859
|
},
|
|
856
860
|
ttf: {
|
|
857
861
|
exclude: function exclude(filePath) {
|
|
858
|
-
return _module.optimizer.font.ttf.exclude === null ? false :
|
|
862
|
+
return _module.optimizer.font.ttf.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.ttf.exclude, filePath);
|
|
859
863
|
},
|
|
860
864
|
generator: {
|
|
861
865
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -872,7 +876,7 @@ var genericLoader = {
|
|
|
872
876
|
},
|
|
873
877
|
woff: {
|
|
874
878
|
exclude: function exclude(filePath) {
|
|
875
|
-
return _module.optimizer.font.woff.exclude === null ? false :
|
|
879
|
+
return _module.optimizer.font.woff.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.woff.exclude, filePath);
|
|
876
880
|
},
|
|
877
881
|
generator: {
|
|
878
882
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -891,7 +895,7 @@ var genericLoader = {
|
|
|
891
895
|
// region image
|
|
892
896
|
image: {
|
|
893
897
|
exclude: function exclude(filePath) {
|
|
894
|
-
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) :
|
|
898
|
+
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.image.exclude, filePath);
|
|
895
899
|
},
|
|
896
900
|
generator: {
|
|
897
901
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.image), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -911,7 +915,7 @@ var genericLoader = {
|
|
|
911
915
|
data: {
|
|
912
916
|
exclude: function exclude(filePath) {
|
|
913
917
|
if (typeof filePath !== 'string') return false;
|
|
914
|
-
return configuration.extensions.file.internal.includes((0, _path.extname)((0, _helper.stripLoader)(filePath))) || (_module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) :
|
|
918
|
+
return configuration.extensions.file.internal.includes((0, _path.extname)((0, _helper.stripLoader)(filePath))) || (_module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.data.exclude, filePath));
|
|
915
919
|
},
|
|
916
920
|
generator: {
|
|
917
921
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.data), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -945,8 +949,8 @@ if (configuration.files.compose.cascadingStyleSheet && plugins.MiniCSSExtract) {
|
|
|
945
949
|
last module which would shadow main module (e.g. index).
|
|
946
950
|
So we inject live reload and hot module replacement manually.
|
|
947
951
|
*/
|
|
948
|
-
if (htmlAvailable && configuration.debug && configuration.development.server.liveReload && !configuration.injection.entry.normalized
|
|
949
|
-
configuration.injection.entry.normalized.developmentHandler = ['webpack-dev-server/client/index.js?' + 'live-reload=
|
|
952
|
+
if (htmlAvailable && configuration.debug && configuration.development.server.liveReload && !Object.prototype.hasOwnProperty.call(configuration.injection.entry.normalized, 'developmentHandler') && (configuration.development.includeClient || typeof configuration.development.includeClient !== 'boolean' && ['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2]))) {
|
|
953
|
+
configuration.injection.entry.normalized.developmentHandler = ['webpack-dev-server/client/index.js?' + 'live-reload=true' + "&hot=".concat(configuration.development.server.hot ? 'true' : 'false') + "&http".concat(configuration.development.server.https ? 's' : '', "://") + "".concat(configuration.development.server.host, ":") + String(configuration.development.server.port)];
|
|
950
954
|
if (configuration.development.server.hot) {
|
|
951
955
|
configuration.injection.entry.normalized.developmentHandler.push('webpack/hot/dev-server.js');
|
|
952
956
|
configuration.development.server.hot = false;
|
|
@@ -994,14 +998,14 @@ if (!_module.optimizer.minimizer) {
|
|
|
994
998
|
// endregion
|
|
995
999
|
// region configuration
|
|
996
1000
|
var customConfiguration = {};
|
|
997
|
-
if (
|
|
1001
|
+
if (configuration.path.configuration.json) try {
|
|
998
1002
|
require.resolve(configuration.path.configuration.json);
|
|
999
1003
|
try {
|
|
1000
1004
|
customConfiguration = currentRequire(configuration.path.configuration.json);
|
|
1001
1005
|
} catch (error) {
|
|
1002
1006
|
console.debug('Importing provided json webpack configuration file path ' + "under \"".concat(configuration.path.configuration.json, "\" failed: ") + (0, _clientnode.represent)(error));
|
|
1003
1007
|
}
|
|
1004
|
-
} catch (
|
|
1008
|
+
} catch (_error) {
|
|
1005
1009
|
console.debug('Optional configuration file "' + "".concat(configuration.path.configuration.json, "\" not available."));
|
|
1006
1010
|
}
|
|
1007
1011
|
var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend)(true, {
|
|
@@ -1076,7 +1080,7 @@ var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend
|
|
|
1076
1080
|
cacheGroups: {
|
|
1077
1081
|
defaultVendors: {
|
|
1078
1082
|
chunks: function chunks(chunk) {
|
|
1079
|
-
if (
|
|
1083
|
+
if (configuration.inPlace.javaScript) for (var _i7 = 0, _Object$keys = Object.keys(configuration.inPlace.javaScript); _i7 < _Object$keys.length; _i7++) {
|
|
1080
1084
|
var _name3 = _Object$keys[_i7];
|
|
1081
1085
|
if (_name3 === '*' || _name3 === chunk.name) return false;
|
|
1082
1086
|
}
|
|
@@ -1102,15 +1106,19 @@ var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend
|
|
|
1102
1106
|
}, (_configuration$cache3 = configuration.cache) !== null && _configuration$cache3 !== void 0 && _configuration$cache3.main ? {
|
|
1103
1107
|
cache: configuration.cache.main
|
|
1104
1108
|
} : {}, configuration.webpack, customConfiguration);
|
|
1105
|
-
if (configuration.nodeENV !== null) webpackConfiguration.optimization.nodeEnv = configuration.nodeENV;
|
|
1106
|
-
|
|
1107
|
-
|
|
1109
|
+
if (configuration.nodeENV !== null) if ((0, _typeof2["default"])(webpackConfiguration.optimization) === 'object') webpackConfiguration.optimization.nodeEnv = configuration.nodeENV;else webpackConfiguration.optimization = {
|
|
1110
|
+
nodeEnv: configuration.nodeENV
|
|
1111
|
+
};
|
|
1112
|
+
if (!Array.isArray(_module.skipParseRegularExpressions) || _module.skipParseRegularExpressions.length) if ((0, _typeof2["default"])(webpackConfiguration.module) === 'object') webpackConfiguration.module.noParse = _module.skipParseRegularExpressions;else webpackConfiguration.module = {
|
|
1113
|
+
noParse: _module.skipParseRegularExpressions
|
|
1114
|
+
};
|
|
1115
|
+
if (configuration.path.configuration.javaScript) try {
|
|
1108
1116
|
require.resolve(configuration.path.configuration.javaScript);
|
|
1109
1117
|
var result = optionalRequire(configuration.path.configuration.javaScript);
|
|
1110
1118
|
if ((0, _clientnode.isPlainObject)(result)) {
|
|
1111
1119
|
if (Object.prototype.hasOwnProperty.call(result, 'replaceWebOptimizer')) exports.webpackConfiguration = webpackConfiguration = result.replaceWebOptimizer;else (0, _clientnode.extend)(true, webpackConfiguration, result);
|
|
1112
1120
|
} else console.debug('Failed to load given JavaScript configuration file path "' + "".concat(configuration.path.configuration.javaScript, "\"."));
|
|
1113
|
-
} catch (
|
|
1121
|
+
} catch (_error) {
|
|
1114
1122
|
console.debug('Optional configuration file script "' + "".concat(configuration.path.configuration.javaScript, "\" not available."));
|
|
1115
1123
|
}
|
|
1116
1124
|
if (configuration.showConfiguration) {
|