UNPKG

2.44 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.getTransforms = exports.indexHtmlTransformFactory = exports.customWebpackConfigTransformFactory = void 0;
13const path = require("node:path");
14const core_1 = require("@angular-devkit/core");
15const common_1 = require("@angular-builders/common");
16const custom_webpack_builder_1 = require("./custom-webpack-builder");
17const customWebpackConfigTransformFactory = (options, { workspaceRoot, target, logger }) => browserWebpackConfig => {
18 return custom_webpack_builder_1.CustomWebpackBuilder.buildWebpackConfig((0, core_1.normalize)(workspaceRoot), options.customWebpackConfig, browserWebpackConfig, options, target, logger);
19};
20exports.customWebpackConfigTransformFactory = customWebpackConfigTransformFactory;
21const indexHtmlTransformFactory = (options, { workspaceRoot, target, logger }) => {
22 if (!options.indexTransform)
23 return null;
24 const transformPath = path.join((0, core_1.getSystemPath)((0, core_1.normalize)(workspaceRoot)), options.indexTransform);
25 const tsConfig = path.join((0, core_1.getSystemPath)((0, core_1.normalize)(workspaceRoot)), options.tsConfig);
26 return (indexHtml) => __awaiter(void 0, void 0, void 0, function* () {
27 const transform = yield (0, common_1.loadModule)(transformPath, tsConfig, logger);
28 return transform(target, indexHtml);
29 });
30};
31exports.indexHtmlTransformFactory = indexHtmlTransformFactory;
32const getTransforms = (options, context) => ({
33 webpackConfiguration: (0, exports.customWebpackConfigTransformFactory)(options, context),
34 indexHtml: (0, exports.indexHtmlTransformFactory)(options, context),
35});
36exports.getTransforms = getTransforms;
37//# sourceMappingURL=transform-factories.js.map
\No newline at end of file