UNPKG

1.49 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const utils_1 = require("../models/webpack-configs/utils");
4// Sort chunks according to a predefined order:
5// inline, polyfills, all scripts, all styles, vendor, main
6function packageChunkSort(appConfig) {
7 let entryPoints = ['inline', 'polyfills', 'sw-register'];
8 const pushExtraEntries = (extraEntry) => {
9 if (entryPoints.indexOf(extraEntry.entry) === -1) {
10 entryPoints.push(extraEntry.entry);
11 }
12 };
13 if (appConfig.scripts) {
14 utils_1.extraEntryParser(appConfig.scripts, './', 'scripts').forEach(pushExtraEntries);
15 }
16 if (appConfig.styles) {
17 utils_1.extraEntryParser(appConfig.styles, './', 'styles').forEach(pushExtraEntries);
18 }
19 entryPoints.push(...['vendor', 'main']);
20 function sort(left, right) {
21 let leftIndex = entryPoints.indexOf(left.names[0]);
22 let rightindex = entryPoints.indexOf(right.names[0]);
23 if (leftIndex > rightindex) {
24 return 1;
25 }
26 else if (leftIndex < rightindex) {
27 return -1;
28 }
29 else {
30 return 0;
31 }
32 }
33 // We need to list of entry points for the Ejected webpack config to work (we reuse the function
34 // defined above).
35 sort.entryPoints = entryPoints;
36 return sort;
37}
38exports.packageChunkSort = packageChunkSort;
39//# sourceMappingURL=/users/hans/sources/angular-cli/utilities/package-chunk-sort.js.map
\No newline at end of file