1 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 |
|
11 | const { generateI18nBrowserWebpackConfigFromContext, } = require('@angular-devkit/build-angular/src/utils/webpack-browser-config');
|
12 | const { getCommonConfig, getStylesConfig, getTypeScriptConfig, } = require('@angular-devkit/build-angular/src/webpack/configs');
|
13 | const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
14 | const { filterOutStylingRules } = require('./utils/filter-out-styling-rules');
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | exports.getWebpackConfig = (baseConfig, { builderOptions, builderContext }) => __awaiter(void 0, void 0, void 0, function* () {
|
24 | var _a, _b, _c;
|
25 | |
26 |
|
27 |
|
28 | const { config: cliConfig } = yield generateI18nBrowserWebpackConfigFromContext(Object.assign(Object.assign({
|
29 |
|
30 | index: 'noop-index', main: 'noop-main', outputPath: 'noop-out' }, builderOptions), {
|
31 |
|
32 | optimization: false, namedChunks: false, progress: false, buildOptimizer: false, aot: false }), builderContext, (wco) => [getCommonConfig(wco), getStylesConfig(wco), getTypeScriptConfig(wco)]);
|
33 | |
34 |
|
35 |
|
36 | const entry = [
|
37 | ...baseConfig.entry,
|
38 | ...((_a = cliConfig.entry.styles) !== null && _a !== void 0 ? _a : []),
|
39 | ...((_b = cliConfig.entry.polyfills) !== null && _b !== void 0 ? _b : []),
|
40 | ];
|
41 |
|
42 |
|
43 | const rulesExcludingStyles = filterOutStylingRules(baseConfig);
|
44 | const module = Object.assign(Object.assign({}, baseConfig.module), { rules: [...cliConfig.module.rules, ...rulesExcludingStyles] });
|
45 | const plugins = [...((_c = cliConfig.plugins) !== null && _c !== void 0 ? _c : []), ...baseConfig.plugins];
|
46 | const resolve = Object.assign(Object.assign({}, baseConfig.resolve), { modules: Array.from(new Set([...baseConfig.resolve.modules, ...cliConfig.resolve.modules])), plugins: [
|
47 | new TsconfigPathsPlugin({
|
48 | configFile: builderOptions.tsConfig,
|
49 | mainFields: ['browser', 'module', 'main'],
|
50 | }),
|
51 | ] });
|
52 | return Object.assign(Object.assign({}, baseConfig), { entry,
|
53 | module,
|
54 | plugins,
|
55 | resolve, resolveLoader: cliConfig.resolveLoader });
|
56 | });
|