weboptimizer 2.0.1235 → 2.0.1237
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/browser.js +20 -62
- package/configurator.js +53 -126
- package/ejsLoader.js +8 -52
- package/helper.js +53 -198
- package/index.js +31 -167
- package/jestEnvironmentBrowser.js +1 -12
- package/jestSetup.js +5 -7
- package/package.json +9 -2
- package/stylelintConfigurator.js +1 -6
- package/type.js +4 -4
- package/webpackConfigurator.js +99 -244
package/webpackConfigurator.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #!/usr/bin/env babel-node
|
|
2
2
|
// -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
3
|
/** @module webpackConfigurator */
|
|
5
4
|
'use strict';
|
|
5
|
+
|
|
6
6
|
/* !
|
|
7
7
|
region header
|
|
8
8
|
Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
|
|
@@ -16,59 +16,36 @@
|
|
|
16
16
|
endregion
|
|
17
17
|
*/
|
|
18
18
|
// region imports
|
|
19
|
-
|
|
20
19
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
21
|
-
|
|
22
20
|
Object.defineProperty(exports, "__esModule", {
|
|
23
21
|
value: true
|
|
24
22
|
});
|
|
25
23
|
exports.webpackConfiguration = exports.optionalRequire = exports["default"] = void 0;
|
|
26
|
-
|
|
27
24
|
var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
|
|
28
|
-
|
|
29
25
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
30
|
-
|
|
31
26
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
32
|
-
|
|
33
27
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
34
|
-
|
|
35
28
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
36
|
-
|
|
37
29
|
var _clientnode = _interopRequireDefault(require("clientnode"));
|
|
38
|
-
|
|
39
30
|
var _jsdom = require("jsdom");
|
|
40
|
-
|
|
41
31
|
var _path = require("path");
|
|
42
|
-
|
|
43
32
|
var _util = _interopRequireDefault(require("util"));
|
|
44
|
-
|
|
45
33
|
var _webpack = require("webpack");
|
|
46
|
-
|
|
47
34
|
var _webpackSources = require("webpack-sources");
|
|
48
|
-
|
|
49
35
|
var _configurator = _interopRequireDefault(require("./configurator"));
|
|
50
|
-
|
|
51
36
|
var _helper = _interopRequireDefault(require("./helper"));
|
|
52
|
-
|
|
53
37
|
var _ejsLoader = _interopRequireDefault(require("./ejsLoader"));
|
|
54
|
-
|
|
55
38
|
var _optionalRequire,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
39
|
+
_this = void 0,
|
|
40
|
+
_configuration$path$c,
|
|
41
|
+
_configuration$cache,
|
|
42
|
+
_configuration$cache2,
|
|
43
|
+
_configuration$path$c2;
|
|
62
44
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
63
|
-
|
|
64
45
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
65
|
-
|
|
66
46
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
67
|
-
|
|
68
47
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
69
|
-
|
|
70
48
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
71
|
-
|
|
72
49
|
/// region optional imports
|
|
73
50
|
// NOTE: Has to be defined here to ensure to resolve from here.
|
|
74
51
|
var currentRequire =
|
|
@@ -77,7 +54,6 @@ var currentRequire =
|
|
|
77
54
|
__non_webpack_require__ :
|
|
78
55
|
*/
|
|
79
56
|
eval("typeof require === 'undefined' ? null : require");
|
|
80
|
-
|
|
81
57
|
var optionalRequire = function optionalRequire(id) {
|
|
82
58
|
try {
|
|
83
59
|
return currentRequire ? currentRequire(id) : null;
|
|
@@ -85,15 +61,14 @@ var optionalRequire = function optionalRequire(id) {
|
|
|
85
61
|
return null;
|
|
86
62
|
}
|
|
87
63
|
};
|
|
88
|
-
|
|
89
64
|
exports.optionalRequire = optionalRequire;
|
|
90
65
|
var postcssCSSnano = optionalRequire('cssnano');
|
|
91
66
|
var postcssFontpath = optionalRequire('postcss-fontpath');
|
|
92
67
|
var postcssImport = optionalRequire('postcss-import');
|
|
93
68
|
var postcssSprites = optionalRequire('postcss-sprites');
|
|
94
69
|
var updateRule = (_optionalRequire = optionalRequire('postcss-sprites/lib/core')) === null || _optionalRequire === void 0 ? void 0 : _optionalRequire.updateRule;
|
|
95
|
-
var postcssURL = optionalRequire('postcss-url');
|
|
96
|
-
|
|
70
|
+
var postcssURL = optionalRequire('postcss-url');
|
|
71
|
+
/// endregion
|
|
97
72
|
var pluginNameResourceMapping = {
|
|
98
73
|
HTML: 'html-webpack-plugin',
|
|
99
74
|
MiniCSSExtract: 'mini-css-extract-plugin',
|
|
@@ -103,26 +78,22 @@ var pluginNameResourceMapping = {
|
|
|
103
78
|
Terser: 'terser-webpack-plugin'
|
|
104
79
|
};
|
|
105
80
|
var plugins = {};
|
|
106
|
-
|
|
107
81
|
for (var _i = 0, _Object$entries = Object.entries(pluginNameResourceMapping); _i < _Object$entries.length; _i++) {
|
|
108
82
|
var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
83
|
+
name = _Object$entries$_i[0],
|
|
84
|
+
alias = _Object$entries$_i[1];
|
|
112
85
|
var plugin = optionalRequire(alias);
|
|
113
86
|
if (plugin) plugins[name] = plugin;else console.debug("Optional webpack plugin \"".concat(name, "\" not available."));
|
|
114
87
|
}
|
|
115
|
-
|
|
116
88
|
if (plugins.Offline) {
|
|
117
89
|
plugins.GenerateServiceWorker = plugins.Offline.GenerateSW;
|
|
118
90
|
plugins.InjectManifest = plugins.Offline.InjectManifest;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
}
|
|
92
|
+
// endregion
|
|
122
93
|
var configuration = (0, _configurator["default"])();
|
|
123
|
-
var _module = configuration.module;
|
|
94
|
+
var _module = configuration.module;
|
|
95
|
+
// region initialisation
|
|
124
96
|
/// region determine library name
|
|
125
|
-
|
|
126
97
|
var libraryName;
|
|
127
98
|
if (configuration.libraryName) libraryName = configuration.libraryName;else if (Object.keys(configuration.injection.entry.normalized).length > 1) libraryName = '[name]';else {
|
|
128
99
|
libraryName = configuration.name;
|
|
@@ -130,88 +101,76 @@ if (configuration.libraryName) libraryName = configuration.libraryName;else if (
|
|
|
130
101
|
}
|
|
131
102
|
if (libraryName === '*') libraryName = ['assign', 'global', 'this', 'var', 'window'].includes(configuration.exportFormat.self) ? Object.keys(configuration.injection.entry.normalized).map(function (name) {
|
|
132
103
|
return _clientnode["default"].stringConvertToValidVariableName(name);
|
|
133
|
-
}) : undefined;
|
|
104
|
+
}) : undefined;
|
|
105
|
+
/// endregion
|
|
134
106
|
/// region plugins
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
107
|
+
var pluginInstances = [];
|
|
108
|
+
//// region define modules to ignore
|
|
138
109
|
var _iterator = _createForOfIteratorHelper([].concat(configuration.injection.ignorePattern)),
|
|
139
|
-
|
|
140
|
-
|
|
110
|
+
_step;
|
|
141
111
|
try {
|
|
142
112
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
143
113
|
var pattern = _step.value;
|
|
144
114
|
if (typeof pattern.contextRegExp === 'string') pattern.contextRegExp = new RegExp(pattern.contextRegExp);
|
|
145
115
|
if (typeof pattern.resourceRegExp === 'string') pattern.resourceRegExp = new RegExp(pattern.resourceRegExp);
|
|
146
116
|
pluginInstances.push(new _webpack.IgnorePlugin(pattern));
|
|
147
|
-
}
|
|
117
|
+
}
|
|
118
|
+
//// endregion
|
|
148
119
|
//// region define modules to replace
|
|
149
|
-
|
|
150
120
|
} catch (err) {
|
|
151
121
|
_iterator.e(err);
|
|
152
122
|
} finally {
|
|
153
123
|
_iterator.f();
|
|
154
124
|
}
|
|
155
|
-
|
|
156
125
|
var _loop = function _loop() {
|
|
157
126
|
var _Object$entries2$_i = (0, _slicedToArray2["default"])(_Object$entries2[_i2], 2),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
127
|
+
source = _Object$entries2$_i[0],
|
|
128
|
+
replacement = _Object$entries2$_i[1];
|
|
161
129
|
var search = new RegExp(source);
|
|
162
130
|
pluginInstances.push(new _webpack.NormalModuleReplacementPlugin(search, function (resource) {
|
|
163
131
|
resource.request = resource.request.replace(search, replacement);
|
|
164
132
|
}));
|
|
165
133
|
};
|
|
166
|
-
|
|
167
134
|
for (var _i2 = 0, _Object$entries2 = Object.entries(_module.replacements.normal); _i2 < _Object$entries2.length; _i2++) {
|
|
168
135
|
_loop();
|
|
169
|
-
}
|
|
136
|
+
}
|
|
137
|
+
//// endregion
|
|
170
138
|
//// region generate html file
|
|
171
|
-
|
|
172
|
-
|
|
173
139
|
var htmlAvailable = false;
|
|
174
|
-
|
|
175
140
|
var _iterator2 = _createForOfIteratorHelper(configuration.files.html),
|
|
176
|
-
|
|
177
|
-
|
|
141
|
+
_step2;
|
|
178
142
|
try {
|
|
179
143
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
180
144
|
var htmlConfiguration = _step2.value;
|
|
181
|
-
|
|
182
145
|
if (_clientnode["default"].isFileSync(htmlConfiguration.template.filePath)) {
|
|
183
146
|
pluginInstances.push(new plugins.HTML(_objectSpread(_objectSpread({}, htmlConfiguration), {}, {
|
|
184
147
|
template: htmlConfiguration.template.request
|
|
185
148
|
})));
|
|
186
149
|
htmlAvailable = true;
|
|
187
150
|
}
|
|
188
|
-
}
|
|
151
|
+
}
|
|
152
|
+
//// endregion
|
|
189
153
|
//// region generate favicons
|
|
190
|
-
|
|
191
154
|
} catch (err) {
|
|
192
155
|
_iterator2.e(err);
|
|
193
156
|
} finally {
|
|
194
157
|
_iterator2.f();
|
|
195
158
|
}
|
|
196
|
-
|
|
197
|
-
|
|
159
|
+
if (htmlAvailable && configuration.favicon && plugins.Favicon && _clientnode["default"].isFileSync(configuration.favicon.logo)) pluginInstances.push(new plugins.Favicon(configuration.favicon));
|
|
160
|
+
//// endregion
|
|
198
161
|
//// region provide offline functionality
|
|
199
|
-
|
|
200
162
|
if (htmlAvailable && configuration.offline && plugins.Offline) {
|
|
201
163
|
if (!['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) for (var _i3 = 0, _Object$entries3 = Object.entries({
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
164
|
+
cascadingStyleSheet: 'css',
|
|
165
|
+
javaScript: 'js'
|
|
166
|
+
}); _i3 < _Object$entries3.length; _i3++) {
|
|
205
167
|
var _Object$entries3$_i = (0, _slicedToArray2["default"])(_Object$entries3[_i3], 2),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
168
|
+
_name = _Object$entries3$_i[0],
|
|
169
|
+
extension = _Object$entries3$_i[1];
|
|
209
170
|
var type = _name;
|
|
210
|
-
|
|
211
171
|
if (configuration.inPlace[type]) {
|
|
212
172
|
var matches = Object.keys(configuration.inPlace[type]);
|
|
213
173
|
if (!Array.isArray(configuration.offline.common.excludeChunks)) configuration.offline.common.excludeChunks = [];
|
|
214
|
-
|
|
215
174
|
for (var _i4 = 0, _matches = matches; _i4 < _matches.length; _i4++) {
|
|
216
175
|
var _name2 = _matches[_i4];
|
|
217
176
|
configuration.offline.common.excludeChunks.push((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset[type]) + "".concat(_name2, ".").concat(extension, "?").concat(configuration.hashAlgorithm, "=*"));
|
|
@@ -220,27 +179,23 @@ if (htmlAvailable && configuration.offline && plugins.Offline) {
|
|
|
220
179
|
}
|
|
221
180
|
if ([].concat(configuration.offline.use).includes('injectionManifest')) pluginInstances.push(new plugins.InjectManifest(_clientnode["default"].extend(true, configuration.offline.common, configuration.offline.injectionManifest)));
|
|
222
181
|
if ([].concat(configuration.offline.use).includes('generateServiceWorker')) pluginInstances.push(new plugins.GenerateServiceWorker(_clientnode["default"].extend(true, configuration.offline.common, configuration.offline.serviceWorker)));
|
|
223
|
-
}
|
|
182
|
+
}
|
|
183
|
+
//// endregion
|
|
224
184
|
//// region provide build environment
|
|
225
|
-
|
|
226
|
-
|
|
227
185
|
if (configuration.buildContext.definitions) pluginInstances.push(new _webpack.DefinePlugin(configuration.buildContext.definitions));
|
|
228
|
-
if (_module.provide) pluginInstances.push(new _webpack.ProvidePlugin(_module.provide));
|
|
186
|
+
if (_module.provide) pluginInstances.push(new _webpack.ProvidePlugin(_module.provide));
|
|
187
|
+
//// endregion
|
|
229
188
|
//// region modules/assets
|
|
230
189
|
///// region apply module pattern
|
|
231
|
-
|
|
232
190
|
pluginInstances.push({
|
|
233
191
|
apply: function apply(compiler) {
|
|
234
192
|
compiler.hooks.emit.tap('applyModulePattern', function (compilation) {
|
|
235
193
|
for (var _i5 = 0, _Object$entries4 = Object.entries(compilation.assets); _i5 < _Object$entries4.length; _i5++) {
|
|
236
194
|
var _Object$entries4$_i = (0, _slicedToArray2["default"])(_Object$entries4[_i5], 2),
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
195
|
+
request = _Object$entries4$_i[0],
|
|
196
|
+
asset = _Object$entries4$_i[1];
|
|
240
197
|
var filePath = request.replace(/\?[^?]+$/, '');
|
|
241
|
-
|
|
242
198
|
var _type2 = _helper["default"].determineAssetType(filePath, configuration.buildContext.types, configuration.path);
|
|
243
|
-
|
|
244
199
|
if (_type2 && configuration.assetPattern[_type2] && new RegExp(configuration.assetPattern[_type2].includeFilePathRegularExpression).test(filePath) && !new RegExp(configuration.assetPattern[_type2].excludeFilePathRegularExpression).test(filePath)) {
|
|
245
200
|
var source = asset.source();
|
|
246
201
|
if (typeof source === 'string') compilation.assets[request] = new _webpackSources.RawSource(configuration.assetPattern[_type2].pattern.replace(/\{1\}/g, source.replace(/\$/g, '$$$')));
|
|
@@ -248,9 +203,9 @@ pluginInstances.push({
|
|
|
248
203
|
}
|
|
249
204
|
});
|
|
250
205
|
}
|
|
251
|
-
});
|
|
206
|
+
});
|
|
207
|
+
///// endregion
|
|
252
208
|
///// region in-place configured assets in the main html file
|
|
253
|
-
|
|
254
209
|
/*
|
|
255
210
|
TODO
|
|
256
211
|
|
|
@@ -282,7 +237,6 @@ if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenComm
|
|
|
282
237
|
var inPlace = function inPlace(type, tag) {
|
|
283
238
|
var settings;
|
|
284
239
|
var url = false;
|
|
285
|
-
|
|
286
240
|
if (tag.tagName === 'script') {
|
|
287
241
|
settings = configuration.inPlace.javaScript;
|
|
288
242
|
url = tag.attributes.src;
|
|
@@ -290,15 +244,12 @@ if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenComm
|
|
|
290
244
|
settings = configuration.inPlace.cascadingStyleSheet;
|
|
291
245
|
url = tag.attributes.href;
|
|
292
246
|
}
|
|
293
|
-
|
|
294
247
|
if (!(url && typeof url === 'string')) return tag;
|
|
295
248
|
var name = publicPath ? url.replace(publicPath, '') : url;
|
|
296
|
-
|
|
297
249
|
if (compilation.assets[name] && settings[type] && [].concat(settings[type]).some(function (pattern) {
|
|
298
250
|
return new RegExp(pattern).test(name);
|
|
299
251
|
})) {
|
|
300
252
|
var newAttributes = _objectSpread({}, tag.attributes);
|
|
301
|
-
|
|
302
253
|
delete newAttributes.href;
|
|
303
254
|
delete newAttributes.src;
|
|
304
255
|
inPlacedAssetNames.push(name);
|
|
@@ -308,19 +259,17 @@ if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenComm
|
|
|
308
259
|
tagName: 'script'
|
|
309
260
|
});
|
|
310
261
|
}
|
|
311
|
-
|
|
312
262
|
return tag;
|
|
313
263
|
};
|
|
314
|
-
|
|
315
264
|
assets.headTags = assets.headTags.map(inPlace.bind(_this, 'head'));
|
|
316
265
|
assets.bodyTags = assets.bodyTags.map(inPlace.bind(_this, 'body'));
|
|
317
266
|
return assets;
|
|
318
|
-
});
|
|
267
|
+
});
|
|
319
268
|
|
|
269
|
+
// NOTE: Avoid if you still want to emit the runtime chunks:
|
|
320
270
|
hooks.afterEmit.tap('inPlaceHTMLAssets', function (asset) {
|
|
321
271
|
var _iterator3 = _createForOfIteratorHelper(inPlacedAssetNames),
|
|
322
|
-
|
|
323
|
-
|
|
272
|
+
_step3;
|
|
324
273
|
try {
|
|
325
274
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
326
275
|
var _name3 = _step3.value;
|
|
@@ -331,23 +280,22 @@ if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenComm
|
|
|
331
280
|
} finally {
|
|
332
281
|
_iterator3.f();
|
|
333
282
|
}
|
|
334
|
-
|
|
335
283
|
return asset;
|
|
336
284
|
});
|
|
337
285
|
});
|
|
338
286
|
}
|
|
339
|
-
});
|
|
287
|
+
});
|
|
288
|
+
///// endregion
|
|
340
289
|
///// region mark empty javaScript modules as dummy
|
|
341
|
-
|
|
342
|
-
|
|
290
|
+
if (!(configuration.needed.javaScript || configuration.needed.javaScriptExtension || configuration.needed.typeScript || configuration.needed.typeScriptExtension)) configuration.files.compose.javaScript = (0, _path.resolve)(configuration.path.target.asset.javaScript, '.__dummy__.compiled.js');
|
|
291
|
+
///// endregion
|
|
343
292
|
///// region extract cascading style sheets
|
|
344
|
-
|
|
345
293
|
var cssOutputPath = configuration.files.compose.cascadingStyleSheet;
|
|
346
294
|
if (cssOutputPath && plugins.MiniCSSExtract) pluginInstances.push(new plugins.MiniCSSExtract({
|
|
347
295
|
filename: typeof cssOutputPath === 'string' ? (0, _path.relative)(configuration.path.target.base, cssOutputPath) : cssOutputPath
|
|
348
|
-
}));
|
|
296
|
+
}));
|
|
297
|
+
///// endregion
|
|
349
298
|
///// region performs implicit external logic
|
|
350
|
-
|
|
351
299
|
if (configuration.injection.external.modules === '__implicit__')
|
|
352
300
|
/*
|
|
353
301
|
We only want to process modules from local context in library mode,
|
|
@@ -358,50 +306,42 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
358
306
|
*/
|
|
359
307
|
configuration.injection.external.modules = function (_ref, callback) {
|
|
360
308
|
var context = _ref.context,
|
|
361
|
-
|
|
309
|
+
request = _ref.request;
|
|
362
310
|
if (typeof request !== 'string') return callback();
|
|
363
311
|
request = request.replace(/^!+/, '');
|
|
364
312
|
if (request.startsWith('/')) request = (0, _path.relative)(configuration.path.context, request);
|
|
365
|
-
|
|
366
313
|
var _iterator4 = _createForOfIteratorHelper(_module.directoryNames),
|
|
367
|
-
|
|
368
|
-
|
|
314
|
+
_step4;
|
|
369
315
|
try {
|
|
370
316
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
371
317
|
var _filePath = _step4.value;
|
|
372
|
-
|
|
373
318
|
if (request.startsWith(_filePath)) {
|
|
374
319
|
request = request.substring(_filePath.length);
|
|
375
320
|
if (request.startsWith('/')) request = request.substring(1);
|
|
376
321
|
break;
|
|
377
322
|
}
|
|
378
|
-
}
|
|
379
|
-
|
|
323
|
+
}
|
|
324
|
+
// region pattern based aliasing
|
|
380
325
|
} catch (err) {
|
|
381
326
|
_iterator4.e(err);
|
|
382
327
|
} finally {
|
|
383
328
|
_iterator4.f();
|
|
384
329
|
}
|
|
385
|
-
|
|
386
330
|
var filePath = _helper["default"].determineModuleFilePath(request, {}, {}, {
|
|
387
331
|
file: configuration.extensions.file.external
|
|
388
332
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
|
|
389
|
-
|
|
390
333
|
if (filePath) for (var _i6 = 0, _Object$entries5 = Object.entries(configuration.injection.external.aliases); _i6 < _Object$entries5.length; _i6++) {
|
|
391
334
|
var _Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i6], 2),
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
335
|
+
pattern = _Object$entries5$_i[0],
|
|
336
|
+
targetConfiguration = _Object$entries5$_i[1];
|
|
395
337
|
if (pattern.startsWith('^')) {
|
|
396
338
|
var regularExpression = new RegExp(pattern);
|
|
397
|
-
|
|
398
339
|
if (regularExpression.test(filePath)) {
|
|
399
340
|
var match = false;
|
|
400
341
|
var firstKey = Object.keys(targetConfiguration)[0];
|
|
401
342
|
var target = targetConfiguration[firstKey];
|
|
402
343
|
if (typeof target !== 'string') break;
|
|
403
344
|
var replacementRegularExpression = new RegExp(firstKey);
|
|
404
|
-
|
|
405
345
|
if (target.startsWith('?')) {
|
|
406
346
|
target = target.substring(1);
|
|
407
347
|
var aliasedRequest = request.replace(replacementRegularExpression, target);
|
|
@@ -409,31 +349,26 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
409
349
|
file: configuration.extensions.file.external
|
|
410
350
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding));
|
|
411
351
|
} else match = true;
|
|
412
|
-
|
|
413
352
|
if (match) {
|
|
414
353
|
request = request.replace(replacementRegularExpression, target);
|
|
415
354
|
break;
|
|
416
355
|
}
|
|
417
356
|
}
|
|
418
357
|
}
|
|
419
|
-
}
|
|
420
|
-
|
|
358
|
+
}
|
|
359
|
+
// endregion
|
|
421
360
|
var resolvedRequest = _helper["default"].determineExternalRequest(request, configuration.path.context, context, configuration.injection.entry.normalized, _module.directoryNames, _module.aliases, _module.replacements.normal, configuration.extensions, configuration.path.source.asset.base, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.injection.external.implicit.pattern.include, configuration.injection.external.implicit.pattern.exclude, configuration.inPlace.externalLibrary.normal, configuration.inPlace.externalLibrary.dynamic, configuration.encoding);
|
|
422
|
-
|
|
423
361
|
if (resolvedRequest) {
|
|
424
362
|
var keys = ['amd', 'commonjs', 'commonjs2', 'root'];
|
|
425
363
|
var result = resolvedRequest;
|
|
426
|
-
|
|
427
364
|
if (Object.prototype.hasOwnProperty.call(configuration.injection.external.aliases, request)) {
|
|
428
365
|
// region normal alias replacement
|
|
429
366
|
result = {
|
|
430
367
|
"default": request
|
|
431
368
|
};
|
|
432
|
-
|
|
433
369
|
if (typeof configuration.injection.external.aliases[request] === 'string') {
|
|
434
370
|
var _iterator5 = _createForOfIteratorHelper(keys),
|
|
435
|
-
|
|
436
|
-
|
|
371
|
+
_step5;
|
|
437
372
|
try {
|
|
438
373
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
439
374
|
var key = _step5.value;
|
|
@@ -446,8 +381,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
446
381
|
}
|
|
447
382
|
} else if (typeof configuration.injection.external.aliases[request] === 'function') {
|
|
448
383
|
var _iterator6 = _createForOfIteratorHelper(keys),
|
|
449
|
-
|
|
450
|
-
|
|
384
|
+
_step6;
|
|
451
385
|
try {
|
|
452
386
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
453
387
|
var _key2 = _step6.value;
|
|
@@ -459,11 +393,9 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
459
393
|
_iterator6.f();
|
|
460
394
|
}
|
|
461
395
|
} else if (configuration.injection.external.aliases[request] !== null && (0, _typeof2["default"])(configuration.injection.external.aliases[request]) === 'object') _clientnode["default"].extend(result, configuration.injection.external.aliases[request]);
|
|
462
|
-
|
|
463
396
|
if (Object.prototype.hasOwnProperty.call(result, 'default')) {
|
|
464
397
|
var _iterator7 = _createForOfIteratorHelper(keys),
|
|
465
|
-
|
|
466
|
-
|
|
398
|
+
_step7;
|
|
467
399
|
try {
|
|
468
400
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
469
401
|
var _key3 = _step7.value;
|
|
@@ -474,8 +406,8 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
474
406
|
} finally {
|
|
475
407
|
_iterator7.f();
|
|
476
408
|
}
|
|
477
|
-
}
|
|
478
|
-
|
|
409
|
+
}
|
|
410
|
+
// endregion
|
|
479
411
|
}
|
|
480
412
|
|
|
481
413
|
if (typeof result !== 'string' && Object.prototype.hasOwnProperty.call(result, 'root')) result.root = [].concat(result.root).map(function (name) {
|
|
@@ -484,12 +416,11 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
484
416
|
var exportFormat = configuration.exportFormat.external || configuration.exportFormat.self;
|
|
485
417
|
return callback(undefined, exportFormat === 'umd' || typeof result === 'string' ? result : result[exportFormat], exportFormat);
|
|
486
418
|
}
|
|
487
|
-
|
|
488
419
|
return callback();
|
|
489
|
-
};
|
|
420
|
+
};
|
|
421
|
+
///// endregion
|
|
490
422
|
//// endregion
|
|
491
423
|
//// region apply final cascadingStyleSheet/dom/javaScript modifications/fixes
|
|
492
|
-
|
|
493
424
|
if (htmlAvailable) pluginInstances.push({
|
|
494
425
|
apply: function apply(compiler) {
|
|
495
426
|
return compiler.hooks.compilation.tap('WebOptimizer', function (compilation) {
|
|
@@ -505,7 +436,6 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
505
436
|
return "".concat(startTag).concat(endTag);
|
|
506
437
|
});
|
|
507
438
|
var dom;
|
|
508
|
-
|
|
509
439
|
try {
|
|
510
440
|
/*
|
|
511
441
|
NOTE: We have to translate template delimiter to html
|
|
@@ -516,20 +446,16 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
516
446
|
} catch (error) {
|
|
517
447
|
return data;
|
|
518
448
|
}
|
|
519
|
-
|
|
520
449
|
var linkables = {
|
|
521
450
|
link: 'href',
|
|
522
451
|
script: 'src'
|
|
523
452
|
};
|
|
524
|
-
|
|
525
453
|
for (var _i7 = 0, _Object$entries6 = Object.entries(linkables); _i7 < _Object$entries6.length; _i7++) {
|
|
526
454
|
var _Object$entries6$_i = (0, _slicedToArray2["default"])(_Object$entries6[_i7], 2),
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
455
|
+
tagName = _Object$entries6$_i[0],
|
|
456
|
+
attributeName = _Object$entries6$_i[1];
|
|
530
457
|
for (var _i8 = 0, _Array$from = Array.from(dom.window.document.querySelectorAll("".concat(tagName, "[").concat(attributeName, "*=\"?") + "".concat(configuration.hashAlgorithm, "=\"]"))); _i8 < _Array$from.length; _i8++) {
|
|
531
458
|
var domNode = _Array$from[_i8];
|
|
532
|
-
|
|
533
459
|
/*
|
|
534
460
|
NOTE: Removing symbols after a "&" in hash
|
|
535
461
|
string is necessary to match the generated
|
|
@@ -542,27 +468,21 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
542
468
|
NOTE: We have to restore template delimiter and style
|
|
543
469
|
contents.
|
|
544
470
|
*/
|
|
545
|
-
|
|
546
|
-
|
|
547
471
|
data.html = dom.serialize().replace(/##\+#\+#\+##/g, '<%').replace(/##-#-#-##/g, '%>').replace(/(<style[^>]*>)[\s\S]*?(<\/style[^>]*>)/gi, function (match, startTag, endTag) {
|
|
548
472
|
return "".concat(startTag).concat(styleContents.shift()) + endTag;
|
|
549
|
-
});
|
|
550
|
-
|
|
473
|
+
});
|
|
474
|
+
// region post compilation
|
|
551
475
|
var _iterator8 = _createForOfIteratorHelper(configuration.files.html),
|
|
552
|
-
|
|
553
|
-
|
|
476
|
+
_step8;
|
|
554
477
|
try {
|
|
555
478
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
556
479
|
var htmlFileSpecification = _step8.value;
|
|
557
|
-
|
|
558
480
|
if (htmlFileSpecification.filename === data.plugin.options.filename) {
|
|
559
481
|
var _iterator9 = _createForOfIteratorHelper([].concat(htmlFileSpecification.template.use)),
|
|
560
|
-
|
|
561
|
-
|
|
482
|
+
_step9;
|
|
562
483
|
try {
|
|
563
484
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
564
485
|
var _loaderConfiguration$;
|
|
565
|
-
|
|
566
486
|
var loaderConfiguration = _step9.value;
|
|
567
487
|
if ((_loaderConfiguration$ = loaderConfiguration.options) !== null && _loaderConfiguration$ !== void 0 && _loaderConfiguration$.compileSteps && typeof loaderConfiguration.options.compileSteps === 'number') data.html = _ejsLoader["default"].bind({
|
|
568
488
|
query: _clientnode["default"].extend(true, loaderConfiguration.options || {}, htmlFileSpecification.template.postCompileOptions)
|
|
@@ -573,27 +493,24 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
573
493
|
} finally {
|
|
574
494
|
_iterator9.f();
|
|
575
495
|
}
|
|
576
|
-
|
|
577
496
|
break;
|
|
578
497
|
}
|
|
579
|
-
}
|
|
580
|
-
|
|
498
|
+
}
|
|
499
|
+
// endregion
|
|
581
500
|
} catch (err) {
|
|
582
501
|
_iterator8.e(err);
|
|
583
502
|
} finally {
|
|
584
503
|
_iterator8.f();
|
|
585
504
|
}
|
|
586
|
-
|
|
587
505
|
return data;
|
|
588
506
|
});
|
|
589
507
|
});
|
|
590
508
|
}
|
|
591
|
-
});
|
|
509
|
+
});
|
|
510
|
+
//// endregion
|
|
592
511
|
//// region context replacements
|
|
593
|
-
|
|
594
512
|
var _iterator10 = _createForOfIteratorHelper(_module.replacements.context),
|
|
595
|
-
|
|
596
|
-
|
|
513
|
+
_step10;
|
|
597
514
|
try {
|
|
598
515
|
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
599
516
|
var contextReplacement = _step10.value;
|
|
@@ -603,55 +520,44 @@ try {
|
|
|
603
520
|
__dirname: __dirname,
|
|
604
521
|
__filename: __filename
|
|
605
522
|
});
|
|
606
|
-
|
|
607
523
|
if (evaluated.error) throw new Error('Error occurred during processing given context ' + "replacement: ".concat(evaluated.error));
|
|
608
524
|
return evaluated.result;
|
|
609
525
|
}))));
|
|
610
|
-
}
|
|
526
|
+
}
|
|
527
|
+
//// endregion
|
|
611
528
|
//// region consolidate duplicated module requests
|
|
612
|
-
|
|
613
529
|
/*
|
|
614
530
|
NOTE: Redundancies usually occur when symlinks aren't converted to their
|
|
615
531
|
real paths since real paths can be de-duplicated by webpack but if two
|
|
616
532
|
linked modules share the same transitive dependency webpack wont recognize
|
|
617
533
|
them as same dependency.
|
|
618
534
|
*/
|
|
619
|
-
|
|
620
535
|
} catch (err) {
|
|
621
536
|
_iterator10.e(err);
|
|
622
537
|
} finally {
|
|
623
538
|
_iterator10.f();
|
|
624
539
|
}
|
|
625
|
-
|
|
626
540
|
if (_module.enforceDeduplication) {
|
|
627
541
|
var absoluteContextPath = (0, _path.resolve)(configuration.path.context);
|
|
628
|
-
|
|
629
542
|
var consolidator = function consolidator(result) {
|
|
630
543
|
var targetPath = result.createData.resource;
|
|
631
|
-
|
|
632
544
|
if (targetPath && /((?:^|\/)node_modules\/.+)/.test(targetPath) && (!targetPath.startsWith(absoluteContextPath) || /((?:^|\/)node_modules\/.+){2}/.test(targetPath)) && _clientnode["default"].isFileSync(targetPath)) {
|
|
633
545
|
var packageDescriptor = _helper["default"].getClosestPackageDescriptor(targetPath);
|
|
634
|
-
|
|
635
546
|
if (packageDescriptor) {
|
|
636
547
|
var pathPrefixes;
|
|
637
548
|
var pathSuffix;
|
|
638
|
-
|
|
639
549
|
if (targetPath.startsWith(absoluteContextPath)) {
|
|
640
550
|
var _matches2 = targetPath.match(/((?:^|.*?\/)node_modules\/)/g);
|
|
641
|
-
|
|
642
551
|
if (_matches2 === null) return;
|
|
643
552
|
pathPrefixes = Array.from(_matches2);
|
|
644
553
|
/*
|
|
645
554
|
Remove last one to avoid replacing with the already set
|
|
646
555
|
path.
|
|
647
556
|
*/
|
|
648
|
-
|
|
649
557
|
pathPrefixes.pop();
|
|
650
558
|
var index = 0;
|
|
651
|
-
|
|
652
559
|
var _iterator11 = _createForOfIteratorHelper(pathPrefixes),
|
|
653
|
-
|
|
654
|
-
|
|
560
|
+
_step11;
|
|
655
561
|
try {
|
|
656
562
|
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
657
563
|
var pathPrefix = _step11.value;
|
|
@@ -663,33 +569,25 @@ if (_module.enforceDeduplication) {
|
|
|
663
569
|
} finally {
|
|
664
570
|
_iterator11.f();
|
|
665
571
|
}
|
|
666
|
-
|
|
667
572
|
pathSuffix = targetPath.replace(/(?:^|.*\/)node_modules\/(.+$)/, '$1');
|
|
668
573
|
} else {
|
|
669
|
-
pathPrefixes = [(0, _path.resolve)(absoluteContextPath, 'node_modules')];
|
|
670
|
-
|
|
574
|
+
pathPrefixes = [(0, _path.resolve)(absoluteContextPath, 'node_modules')];
|
|
575
|
+
// Find longest common prefix.
|
|
671
576
|
var _index = 0;
|
|
672
|
-
|
|
673
577
|
while (_index < absoluteContextPath.length && absoluteContextPath.charAt(_index) === targetPath.charAt(_index)) {
|
|
674
578
|
_index += 1;
|
|
675
579
|
}
|
|
676
|
-
|
|
677
580
|
pathSuffix = targetPath.substring(_index).replace(/^.*\/node_modules\//, '');
|
|
678
581
|
}
|
|
679
|
-
|
|
680
582
|
var redundantRequest = null;
|
|
681
|
-
|
|
682
583
|
var _iterator12 = _createForOfIteratorHelper(pathPrefixes),
|
|
683
|
-
|
|
684
|
-
|
|
584
|
+
_step12;
|
|
685
585
|
try {
|
|
686
586
|
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
687
587
|
var _pathPrefix = _step12.value;
|
|
688
588
|
var alternateTargetPath = (0, _path.resolve)(_pathPrefix, pathSuffix);
|
|
689
|
-
|
|
690
589
|
if (_clientnode["default"].isFileSync(alternateTargetPath)) {
|
|
691
590
|
var otherPackageDescriptor = _helper["default"].getClosestPackageDescriptor(alternateTargetPath);
|
|
692
|
-
|
|
693
591
|
if (otherPackageDescriptor) {
|
|
694
592
|
if (packageDescriptor.configuration.version === otherPackageDescriptor.configuration.version) {
|
|
695
593
|
console.info('\nConsolidate module request "' + "".concat(targetPath, "\" to \"") + "".concat(alternateTargetPath, "\"."));
|
|
@@ -700,11 +598,9 @@ if (_module.enforceDeduplication) {
|
|
|
700
598
|
"NormaleModuleReplacementPlugin" does
|
|
701
599
|
not always work.
|
|
702
600
|
*/
|
|
703
|
-
|
|
704
601
|
result.request = result.createData.rawRequest = result.createData.request = result.createData.resource = result.createData.userRequest = alternateTargetPath;
|
|
705
602
|
return;
|
|
706
603
|
}
|
|
707
|
-
|
|
708
604
|
redundantRequest = {
|
|
709
605
|
path: alternateTargetPath,
|
|
710
606
|
version: otherPackageDescriptor.configuration.version
|
|
@@ -717,12 +613,10 @@ if (_module.enforceDeduplication) {
|
|
|
717
613
|
} finally {
|
|
718
614
|
_iterator12.f();
|
|
719
615
|
}
|
|
720
|
-
|
|
721
616
|
if (redundantRequest) console.warn('\nIncluding different versions of same package "' + "".concat(packageDescriptor.configuration.name, "\". Module \"") + "".concat(targetPath, "\" (version ") + "".concat(packageDescriptor.configuration.version, ") has ") + "redundancies with \"".concat(redundantRequest.path, "\" (") + "version ".concat(redundantRequest.version, ")."));
|
|
722
617
|
}
|
|
723
618
|
}
|
|
724
619
|
};
|
|
725
|
-
|
|
726
620
|
pluginInstances.push({
|
|
727
621
|
apply: function apply(compiler) {
|
|
728
622
|
return compiler.hooks.normalModuleFactory.tap('WebOptimizerModuleConsolidation', function (nmf) {
|
|
@@ -816,8 +710,6 @@ new NormalModuleReplacementPlugin(
|
|
|
816
710
|
//// endregion
|
|
817
711
|
/// endregion
|
|
818
712
|
/// region loader helper
|
|
819
|
-
|
|
820
|
-
|
|
821
713
|
var isFilePathInDependencies = function isFilePathInDependencies(filePath) {
|
|
822
714
|
filePath = _helper["default"].stripLoader(filePath);
|
|
823
715
|
return _helper["default"].isFilePathInLocation(filePath, configuration.path.ignore.concat(_module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
|
|
@@ -826,7 +718,6 @@ var isFilePathInDependencies = function isFilePathInDependencies(filePath) {
|
|
|
826
718
|
return !configuration.path.context.startsWith(filePath);
|
|
827
719
|
}));
|
|
828
720
|
};
|
|
829
|
-
|
|
830
721
|
var loader = {};
|
|
831
722
|
var scope = {
|
|
832
723
|
configuration: configuration,
|
|
@@ -834,26 +725,20 @@ var scope = {
|
|
|
834
725
|
loader: loader,
|
|
835
726
|
require: currentRequire
|
|
836
727
|
};
|
|
837
|
-
|
|
838
728
|
var evaluate = function evaluate(object) {
|
|
839
729
|
var filePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : configuration.path.context;
|
|
840
|
-
|
|
841
730
|
if (typeof object === 'string') {
|
|
842
731
|
var evaluated = _clientnode["default"].stringEvaluate(object, _objectSpread({
|
|
843
732
|
filePath: filePath
|
|
844
733
|
}, scope));
|
|
845
|
-
|
|
846
734
|
if (evaluated.error) throw new Error('Error occurred during processing given expression: ' + evaluated.error);
|
|
847
735
|
return evaluated.result;
|
|
848
736
|
}
|
|
849
|
-
|
|
850
737
|
return object;
|
|
851
738
|
};
|
|
852
|
-
|
|
853
739
|
var evaluateMapper = function evaluateMapper(value) {
|
|
854
740
|
return evaluate(value);
|
|
855
741
|
};
|
|
856
|
-
|
|
857
742
|
var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderConfiguration(loaderConfiguration) {
|
|
858
743
|
return {
|
|
859
744
|
exclude: function exclude(filePath) {
|
|
@@ -864,9 +749,7 @@ var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderCon
|
|
|
864
749
|
use: evaluate(loaderConfiguration.use)
|
|
865
750
|
};
|
|
866
751
|
};
|
|
867
|
-
|
|
868
752
|
var includingPaths = _helper["default"].normalizePaths([configuration.path.source.asset.javaScript].concat(_module.locations.directoryPaths));
|
|
869
|
-
|
|
870
753
|
var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluateMapper).concat({
|
|
871
754
|
loader: _module.style.loader,
|
|
872
755
|
options: _module.style.options || {}
|
|
@@ -912,7 +795,6 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
912
795
|
onSaveSpritesheet: function onSaveSpritesheet(image) {
|
|
913
796
|
return (0, _path.join)(image.spritePath, (0, _path.relative)(configuration.path.target.asset.image, configuration.files.compose.image));
|
|
914
797
|
},
|
|
915
|
-
|
|
916
798
|
/*
|
|
917
799
|
Reset this token due to a
|
|
918
800
|
sprite bug with
|
|
@@ -934,7 +816,6 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
934
816
|
}
|
|
935
817
|
} : {}, _module.preprocessor.cascadingStyleSheet.options || {})
|
|
936
818
|
} : [], _module.preprocessor.cascadingStyleSheet.additional.post.map(evaluateMapper));
|
|
937
|
-
|
|
938
819
|
var genericLoader = {
|
|
939
820
|
// Convert to compatible native web types.
|
|
940
821
|
// region generic template
|
|
@@ -965,11 +846,9 @@ var genericLoader = {
|
|
|
965
846
|
},
|
|
966
847
|
include: function include(filePath) {
|
|
967
848
|
var result = evaluate(_module.preprocessor.javaScript.include, filePath);
|
|
968
|
-
|
|
969
849
|
if ([null, undefined].includes(result)) {
|
|
970
850
|
var _iterator13 = _createForOfIteratorHelper(includingPaths),
|
|
971
|
-
|
|
972
|
-
|
|
851
|
+
_step13;
|
|
973
852
|
try {
|
|
974
853
|
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
975
854
|
var includePath = _step13.value;
|
|
@@ -980,10 +859,8 @@ var genericLoader = {
|
|
|
980
859
|
} finally {
|
|
981
860
|
_iterator13.f();
|
|
982
861
|
}
|
|
983
|
-
|
|
984
862
|
return false;
|
|
985
863
|
}
|
|
986
|
-
|
|
987
864
|
return Boolean(result);
|
|
988
865
|
},
|
|
989
866
|
test: new RegExp(_module.preprocessor.javaScript.regularExpression, 'i'),
|
|
@@ -1051,11 +928,9 @@ var genericLoader = {
|
|
|
1051
928
|
},
|
|
1052
929
|
include: function include(filePath) {
|
|
1053
930
|
var result = evaluate(_module.cascadingStyleSheet.include, filePath);
|
|
1054
|
-
|
|
1055
931
|
if ([null, undefined].includes(result)) {
|
|
1056
932
|
var _iterator14 = _createForOfIteratorHelper(includingPaths),
|
|
1057
|
-
|
|
1058
|
-
|
|
933
|
+
_step14;
|
|
1059
934
|
try {
|
|
1060
935
|
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1061
936
|
var includePath = _step14.value;
|
|
@@ -1066,10 +941,8 @@ var genericLoader = {
|
|
|
1066
941
|
} finally {
|
|
1067
942
|
_iterator14.f();
|
|
1068
943
|
}
|
|
1069
|
-
|
|
1070
944
|
return false;
|
|
1071
945
|
}
|
|
1072
|
-
|
|
1073
946
|
return Boolean(result);
|
|
1074
947
|
},
|
|
1075
948
|
test: /\.s?css(?:\?.*)?$/i,
|
|
@@ -1184,12 +1057,11 @@ var genericLoader = {
|
|
|
1184
1057
|
}
|
|
1185
1058
|
},
|
|
1186
1059
|
use: _module.optimizer.data.loader.map(evaluateMapper)
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1060
|
+
}
|
|
1061
|
+
// endregion
|
|
1189
1062
|
};
|
|
1190
1063
|
|
|
1191
1064
|
_clientnode["default"].extend(loader, genericLoader);
|
|
1192
|
-
|
|
1193
1065
|
if (configuration.files.compose.cascadingStyleSheet && plugins.MiniCSSExtract) {
|
|
1194
1066
|
/*
|
|
1195
1067
|
NOTE: We have to remove the client side javascript hmr style loader
|
|
@@ -1199,50 +1071,42 @@ if (configuration.files.compose.cascadingStyleSheet && plugins.MiniCSSExtract) {
|
|
|
1199
1071
|
loader.style.use.unshift({
|
|
1200
1072
|
loader: plugins.MiniCSSExtract.loader
|
|
1201
1073
|
});
|
|
1202
|
-
}
|
|
1074
|
+
}
|
|
1075
|
+
/// endregion
|
|
1203
1076
|
/// region apply runtime dev helper
|
|
1204
|
-
|
|
1205
1077
|
/*
|
|
1206
1078
|
NOTE: Disable automatic injection to avoid injection in all chunks and as
|
|
1207
1079
|
last module which would shadow main module (e.g. index).
|
|
1208
1080
|
So we inject live reload and hot module replacement manually.
|
|
1209
1081
|
*/
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
1082
|
if (htmlAvailable && configuration.debug && configuration.development.server.liveReload && !configuration.injection.entry.normalized.developmentHandler && ['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) {
|
|
1213
1083
|
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, ":") + "".concat(configuration.development.server.port)];
|
|
1214
|
-
|
|
1215
1084
|
if (configuration.development.server.hot) {
|
|
1216
1085
|
configuration.injection.entry.normalized.developmentHandler.push('webpack/hot/dev-server.js');
|
|
1217
1086
|
configuration.development.server.hot = false;
|
|
1218
1087
|
pluginInstances.push(new _webpack.HotModuleReplacementPlugin());
|
|
1219
1088
|
}
|
|
1220
|
-
}
|
|
1089
|
+
}
|
|
1090
|
+
/// endregion
|
|
1221
1091
|
// endregion
|
|
1222
1092
|
// region plugins
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
1093
|
var _iterator15 = _createForOfIteratorHelper(configuration.plugins),
|
|
1226
|
-
|
|
1227
|
-
|
|
1094
|
+
_step15;
|
|
1228
1095
|
try {
|
|
1229
1096
|
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
1230
1097
|
var pluginConfiguration = _step15.value;
|
|
1231
|
-
|
|
1232
1098
|
var _plugin = optionalRequire(pluginConfiguration.name.module);
|
|
1233
|
-
|
|
1234
1099
|
if (_plugin) pluginInstances.push((0, _construct2["default"])(_plugin[pluginConfiguration.name.initializer], (0, _toConsumableArray2["default"])(pluginConfiguration.parameters)));else console.warn("Configured plugin module \"".concat(pluginConfiguration.name.module, "\" ") + 'could not be loaded.');
|
|
1235
|
-
}
|
|
1100
|
+
}
|
|
1101
|
+
// endregion
|
|
1236
1102
|
// region minimizer and image compression
|
|
1237
1103
|
// NOTE: This plugin should be loaded at last to ensure that all emitted images
|
|
1238
1104
|
// ran through.
|
|
1239
|
-
|
|
1240
1105
|
} catch (err) {
|
|
1241
1106
|
_iterator15.e(err);
|
|
1242
1107
|
} finally {
|
|
1243
1108
|
_iterator15.f();
|
|
1244
1109
|
}
|
|
1245
|
-
|
|
1246
1110
|
if (!_module.optimizer.minimizer) {
|
|
1247
1111
|
_module.optimizer.minimizer = [];
|
|
1248
1112
|
if (plugins.Terser)
|
|
@@ -1260,14 +1124,12 @@ if (!_module.optimizer.minimizer) {
|
|
|
1260
1124
|
implementation: plugins.ImageMinimizer.imageminMinify
|
|
1261
1125
|
}
|
|
1262
1126
|
}, _module.optimizer.image.content)));
|
|
1263
|
-
}
|
|
1127
|
+
}
|
|
1128
|
+
// endregion
|
|
1264
1129
|
// region configuration
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
1130
|
var customConfiguration = {};
|
|
1268
1131
|
if ((_configuration$path$c = configuration.path.configuration) !== null && _configuration$path$c !== void 0 && _configuration$path$c.json) try {
|
|
1269
1132
|
require.resolve(configuration.path.configuration.json);
|
|
1270
|
-
|
|
1271
1133
|
try {
|
|
1272
1134
|
customConfiguration = currentRequire(configuration.path.configuration.json);
|
|
1273
1135
|
} catch (error) {
|
|
@@ -1276,7 +1138,6 @@ if ((_configuration$path$c = configuration.path.configuration) !== null && _conf
|
|
|
1276
1138
|
} catch (error) {
|
|
1277
1139
|
console.debug('Optional configuration file "' + "".concat(configuration.path.configuration.json, "\" not available."));
|
|
1278
1140
|
}
|
|
1279
|
-
|
|
1280
1141
|
var webpackConfiguration = _clientnode["default"].extend(true, {
|
|
1281
1142
|
bail: !configuration.givenCommandLineArguments.includes('--watch'),
|
|
1282
1143
|
context: configuration.path.context,
|
|
@@ -1323,7 +1184,6 @@ var webpackConfiguration = _clientnode["default"].extend(true, {
|
|
|
1323
1184
|
publicPath: configuration.path.target["public"]
|
|
1324
1185
|
},
|
|
1325
1186
|
performance: configuration.performanceHints,
|
|
1326
|
-
|
|
1327
1187
|
/*
|
|
1328
1188
|
NOTE: Live-reload is not working if target technology is not set to
|
|
1329
1189
|
"web". Webpack boilerplate code may not support target
|
|
@@ -1376,13 +1236,11 @@ var webpackConfiguration = _clientnode["default"].extend(true, {
|
|
|
1376
1236
|
}, (_configuration$cache2 = configuration.cache) !== null && _configuration$cache2 !== void 0 && _configuration$cache2.main ? {
|
|
1377
1237
|
cache: configuration.cache.main
|
|
1378
1238
|
} : {}, configuration.webpack, customConfiguration);
|
|
1379
|
-
|
|
1380
1239
|
exports.webpackConfiguration = webpackConfiguration;
|
|
1381
1240
|
if (configuration.nodeENV !== null) webpackConfiguration.optimization.nodeEnv = configuration.nodeENV;
|
|
1382
1241
|
if (!Array.isArray(_module.skipParseRegularExpressions) || _module.skipParseRegularExpressions.length) webpackConfiguration.module.noParse = _module.skipParseRegularExpressions;
|
|
1383
1242
|
if ((_configuration$path$c2 = configuration.path.configuration) !== null && _configuration$path$c2 !== void 0 && _configuration$path$c2.javaScript) try {
|
|
1384
1243
|
require.resolve(configuration.path.configuration.javaScript);
|
|
1385
|
-
|
|
1386
1244
|
var result = optionalRequire(configuration.path.configuration.javaScript);
|
|
1387
1245
|
if (_clientnode["default"].isPlainObject(result)) {
|
|
1388
1246
|
if (Object.prototype.hasOwnProperty.call(result, 'replaceWebOptimizer')) exports.webpackConfiguration = webpackConfiguration = result.replaceWebOptimizer;else _clientnode["default"].extend(true, webpackConfiguration, result);
|
|
@@ -1390,7 +1248,6 @@ if ((_configuration$path$c2 = configuration.path.configuration) !== null && _con
|
|
|
1390
1248
|
} catch (error) {
|
|
1391
1249
|
console.debug('Optional configuration file script "' + "".concat(configuration.path.configuration.javaScript, "\" not available."));
|
|
1392
1250
|
}
|
|
1393
|
-
|
|
1394
1251
|
if (configuration.showConfiguration) {
|
|
1395
1252
|
console.info('Using internal configuration:', _util["default"].inspect(configuration, {
|
|
1396
1253
|
depth: null
|
|
@@ -1399,12 +1256,10 @@ if (configuration.showConfiguration) {
|
|
|
1399
1256
|
console.info('Using webpack configuration:', _util["default"].inspect(webpackConfiguration, {
|
|
1400
1257
|
depth: null
|
|
1401
1258
|
}));
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1259
|
+
}
|
|
1260
|
+
// endregion
|
|
1405
1261
|
var _default = webpackConfiguration; // region vim modline
|
|
1406
1262
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
1407
1263
|
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
1408
1264
|
// endregion
|
|
1409
|
-
|
|
1410
1265
|
exports["default"] = _default;
|