@angular-builders/custom-webpack 14.0.2-beta.0 → 14.1.0-beta.0
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/README.md +55 -0
- package/dist/browser/schema.json +17 -0
- package/dist/custom-webpack-builder-config.d.ts +4 -0
- package/dist/custom-webpack-builder.d.ts +1 -1
- package/dist/custom-webpack-builder.js +31 -10
- package/dist/custom-webpack-builder.js.map +1 -1
- package/dist/karma/schema.json +17 -0
- package/dist/server/schema.json +17 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,6 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
Allow customizing build configuration without ejecting webpack configuration (`ng eject`)
|
|
6
6
|
|
|
7
|
+
# Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Usage](#usage)
|
|
10
|
+
- [For Example](#for-example)
|
|
11
|
+
- [Builders](#builders)
|
|
12
|
+
- [Custom Webpack `browser`](#custom-webpack-browser)
|
|
13
|
+
- [Custom Webpack `dev-server`](#custom-webpack-dev-server)
|
|
14
|
+
- [Example](#example)
|
|
15
|
+
- [Custom Webpack `server`](#custom-webpack-server)
|
|
16
|
+
- [Custom Webpack `karma`](#custom-webpack-karma)
|
|
17
|
+
- [Custom Webpack `extract-i18n`](#custom-webpack-extract-i18n)
|
|
18
|
+
- [Example](#example-1)
|
|
19
|
+
- [Custom Webpack Config Object](#custom-webpack-config-object)
|
|
20
|
+
- [Merging Plugins Configuration:](#merging-plugins-configuration-)
|
|
21
|
+
- [Custom Webpack Promisified Config](#custom-webpack-promisified-config)
|
|
22
|
+
- [Custom Webpack Config Function](#custom-webpack-config-function)
|
|
23
|
+
- [Index Transform](#index-transform)
|
|
24
|
+
- [Example](#example-2)
|
|
25
|
+
- [ES Modules (ESM) Support](#es-modules-esm-support)
|
|
26
|
+
- [Verbose Logging](#verbose-logging)
|
|
27
|
+
- [Further Reading](#further-reading)
|
|
28
|
+
|
|
7
29
|
# This documentation is for the latest major version only
|
|
8
30
|
|
|
9
31
|
## Previous versions
|
|
@@ -504,6 +526,39 @@ Custom Webpack builder fully supports ESM.
|
|
|
504
526
|
- If you want to use TS config in ESM app, you must set the loader to `ts-node/esm` when running `ng build`. Also, in that case `tsconfig.json` for `ts-node` no longer defaults to `tsConfig` from the `browser` target - you have to specify it manually via environment variable. [Example](../../examples/custom-webpack/sanity-app-esm/package.json#L10).
|
|
505
527
|
_Note that tsconfig paths are not supported in TS configs within ESM apps. That is because [tsconfig-paths](https://github.com/dividab/tsconfig-paths) do not support ESM._
|
|
506
528
|
|
|
529
|
+
# Verbose Logging
|
|
530
|
+
|
|
531
|
+
Custom Webpack allows enabling verbose logging for configuration properties. This can be achieved by providing the `verbose` object in builder options. Given the following example:
|
|
532
|
+
|
|
533
|
+
```json
|
|
534
|
+
{
|
|
535
|
+
"builder": "@angular-builders/custom-webpack:browser",
|
|
536
|
+
"options": {
|
|
537
|
+
"customWebpackConfig": {
|
|
538
|
+
"verbose": {
|
|
539
|
+
"properties": ["entry"]
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
`properties` is an array of strings that supports individual or deeply nested keys (`output.publicPath` and `plugins[0]` are valid keys). The number of times to recurse the object while formatting before it's logged is controlled by the `serializationDepth` property:
|
|
547
|
+
|
|
548
|
+
```json
|
|
549
|
+
{
|
|
550
|
+
"builder": "@angular-builders/custom-webpack:browser",
|
|
551
|
+
"options": {
|
|
552
|
+
"customWebpackConfig": {
|
|
553
|
+
"verbose": {
|
|
554
|
+
"properties": ["plugins[0]"],
|
|
555
|
+
"serializationDepth": 5
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
507
562
|
# Further Reading
|
|
508
563
|
|
|
509
564
|
- [Customizing Angular CLI build - an alternative to ng eject](https://medium.com/angular-in-depth/customizing-angular-cli-build-an-alternative-to-ng-eject-v2-c655768b48cc)
|
package/dist/browser/schema.json
CHANGED
|
@@ -456,6 +456,23 @@
|
|
|
456
456
|
"replaceDuplicatePlugins": {
|
|
457
457
|
"type": "boolean",
|
|
458
458
|
"description": "Flag that indicates whether to replace duplicate webpack plugins or not"
|
|
459
|
+
},
|
|
460
|
+
"verbose": {
|
|
461
|
+
"type": "object",
|
|
462
|
+
"description": "Determines whether to log configuration properties into a console",
|
|
463
|
+
"properties": {
|
|
464
|
+
"properties": {
|
|
465
|
+
"description": "A list of properties to log into a console, for instance, `['plugins', 'mode', 'entry']`",
|
|
466
|
+
"type": "array",
|
|
467
|
+
"items": {
|
|
468
|
+
"type": "string"
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
"serializationDepth": {
|
|
472
|
+
"type": "number",
|
|
473
|
+
"description": "The number of times to recurse the object while formatting"
|
|
474
|
+
}
|
|
475
|
+
}
|
|
459
476
|
}
|
|
460
477
|
}
|
|
461
478
|
},
|
|
@@ -4,5 +4,5 @@ import { CustomWebpackBuilderConfig } from './custom-webpack-builder-config';
|
|
|
4
4
|
import { TargetOptions } from './type-definition';
|
|
5
5
|
export declare const defaultWebpackConfigPath = "webpack.config.js";
|
|
6
6
|
export declare class CustomWebpackBuilder {
|
|
7
|
-
static buildWebpackConfig(root: Path, config: CustomWebpackBuilderConfig, baseWebpackConfig: Configuration, buildOptions: any, targetOptions: TargetOptions, logger: logging.LoggerApi): Promise<Configuration>;
|
|
7
|
+
static buildWebpackConfig(root: Path, config: CustomWebpackBuilderConfig | null, baseWebpackConfig: Configuration, buildOptions: any, targetOptions: TargetOptions, logger: logging.LoggerApi): Promise<Configuration>;
|
|
8
8
|
}
|
|
@@ -10,7 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CustomWebpackBuilder = exports.defaultWebpackConfigPath = void 0;
|
|
13
|
+
const util_1 = require("util");
|
|
13
14
|
const core_1 = require("@angular-devkit/core");
|
|
15
|
+
const lodash_1 = require("lodash");
|
|
14
16
|
const utils_1 = require("./utils");
|
|
15
17
|
const webpack_config_merger_1 = require("./webpack-config-merger");
|
|
16
18
|
exports.defaultWebpackConfigPath = 'webpack.config.js';
|
|
@@ -25,19 +27,22 @@ class CustomWebpackBuilder {
|
|
|
25
27
|
const tsConfig = `${(0, core_1.getSystemPath)(root)}/${buildOptions.tsConfig}`;
|
|
26
28
|
const configOrFactoryOrPromise = yield resolveCustomWebpackConfig(path, tsConfig, logger);
|
|
27
29
|
if (typeof configOrFactoryOrPromise === 'function') {
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// The exported function can return a new configuration synchronously
|
|
31
|
+
// or return a promise that resolves to a new configuration.
|
|
32
|
+
const finalWebpackConfig = yield configOrFactoryOrPromise(baseWebpackConfig, buildOptions, targetOptions);
|
|
33
|
+
logConfigProperties(config, finalWebpackConfig, logger);
|
|
34
|
+
return finalWebpackConfig;
|
|
32
35
|
}
|
|
33
|
-
// The user can also export a
|
|
34
|
-
//
|
|
36
|
+
// The user can also export a promise that resolves to a `Configuration` object.
|
|
37
|
+
// Suppose the following example:
|
|
35
38
|
// `module.exports = new Promise(resolve => resolve({ ... }))`
|
|
36
|
-
//
|
|
37
|
-
// `module.exports = { ... }
|
|
38
|
-
//
|
|
39
|
+
// This is valid both for promise and non-promise cases. If users export
|
|
40
|
+
// a plain object, for instance, `module.exports = { ... }`, then it will
|
|
41
|
+
// be wrapped into a promise and also `awaited`.
|
|
39
42
|
const resolvedConfig = yield configOrFactoryOrPromise;
|
|
40
|
-
|
|
43
|
+
const finalWebpackConfig = (0, webpack_config_merger_1.mergeConfigs)(baseWebpackConfig, resolvedConfig, config.mergeRules, config.replaceDuplicatePlugins);
|
|
44
|
+
logConfigProperties(config, finalWebpackConfig, logger);
|
|
45
|
+
return finalWebpackConfig;
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
}
|
|
@@ -48,4 +53,20 @@ function resolveCustomWebpackConfig(path, tsConfig, logger) {
|
|
|
48
53
|
return (0, utils_1.loadModule)(path);
|
|
49
54
|
});
|
|
50
55
|
}
|
|
56
|
+
function logConfigProperties(config, webpackConfig, logger) {
|
|
57
|
+
var _a;
|
|
58
|
+
// There's no reason to log the entire configuration object
|
|
59
|
+
// since Angular's Webpack configuration is huge by default
|
|
60
|
+
// and doesn't bring any meaningful context by being printed
|
|
61
|
+
// entirely. Users can provide a list of properties they want to be logged.
|
|
62
|
+
if ((_a = config.verbose) === null || _a === void 0 ? void 0 : _a.properties) {
|
|
63
|
+
for (const property of config.verbose.properties) {
|
|
64
|
+
const value = (0, lodash_1.get)(webpackConfig, property);
|
|
65
|
+
if (value) {
|
|
66
|
+
const message = (0, util_1.inspect)(value, /* showHidden */ false, config.verbose.serializationDepth);
|
|
67
|
+
logger.info(message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
51
72
|
//# sourceMappingURL=custom-webpack-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-webpack-builder.js","sourceRoot":"","sources":["../src/custom-webpack-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoE;
|
|
1
|
+
{"version":3,"file":"custom-webpack-builder.js","sourceRoot":"","sources":["../src/custom-webpack-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,+CAAoE;AACpE,mCAA6B;AAK7B,mCAAqD;AACrD,mEAAuD;AAE1C,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAgB5D,MAAa,oBAAoB;IAC/B,MAAM,CAAO,kBAAkB,CAC7B,IAAU,EACV,MAAyC,EACzC,iBAAgC,EAChC,YAAiB,EACjB,aAA4B,EAC5B,MAAyB;;YAEzB,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,iBAAiB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mB,CAC1B,MAAkC,EAClC,aAA4B,EAC5B,MAAyB;;IAEzB,2DAA2D;IAC3D,2DAA2D;IAC3D,4DAA4D;IAC5D,2EAA2E;IAC3E,IAAI,MAAA,MAAM,CAAC,OAAO,0CAAE,UAAU,EAAE;QAC9B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE;YAChD,MAAM,KAAK,GAAG,IAAA,YAAG,EAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;YAC3C,IAAI,KAAK,EAAE;gBACT,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;gBAC1F,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACtB;SACF;KACF;AACH,CAAC"}
|
package/dist/karma/schema.json
CHANGED
|
@@ -271,6 +271,23 @@
|
|
|
271
271
|
"replaceDuplicatePlugins": {
|
|
272
272
|
"type": "boolean",
|
|
273
273
|
"description": "Flag that indicates whether to replace duplicate webpack plugins or not"
|
|
274
|
+
},
|
|
275
|
+
"verbose": {
|
|
276
|
+
"type": "object",
|
|
277
|
+
"description": "Determines whether to log configuration properties into a console",
|
|
278
|
+
"properties": {
|
|
279
|
+
"properties": {
|
|
280
|
+
"description": "A list of properties to log into a console, for instance, `['plugins', 'mode', 'entry']`",
|
|
281
|
+
"type": "array",
|
|
282
|
+
"items": {
|
|
283
|
+
"type": "string"
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"serializationDepth": {
|
|
287
|
+
"type": "number",
|
|
288
|
+
"description": "The number of times to recurse the object while formatting"
|
|
289
|
+
}
|
|
290
|
+
}
|
|
274
291
|
}
|
|
275
292
|
}
|
|
276
293
|
},
|
package/dist/server/schema.json
CHANGED
|
@@ -255,6 +255,23 @@
|
|
|
255
255
|
"replaceDuplicatePlugins": {
|
|
256
256
|
"type": "boolean",
|
|
257
257
|
"description": "Flag that indicates whether to replace duplicate webpack plugins or not"
|
|
258
|
+
},
|
|
259
|
+
"verbose": {
|
|
260
|
+
"type": "object",
|
|
261
|
+
"description": "Determines whether to log configuration properties into a console",
|
|
262
|
+
"properties": {
|
|
263
|
+
"properties": {
|
|
264
|
+
"description": "A list of properties to log into a console, for instance, `['plugins', 'mode', 'entry']`",
|
|
265
|
+
"type": "array",
|
|
266
|
+
"items": {
|
|
267
|
+
"type": "string"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"serializationDepth": {
|
|
271
|
+
"type": "number",
|
|
272
|
+
"description": "The number of times to recurse the object while formatting"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
258
275
|
}
|
|
259
276
|
}
|
|
260
277
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-builders/custom-webpack",
|
|
3
|
-
"version": "14.0
|
|
3
|
+
"version": "14.1.0-beta.0",
|
|
4
4
|
"description": "Custom webpack builders for Angular build facade. Allow to modify Angular build configuration without ejecting it",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"rimraf": "^3.0.2",
|
|
57
57
|
"typescript": "4.7.4"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "a25173b0bc295f248e2df35d614825f4aac8a015"
|
|
60
60
|
}
|