Skip to content

Commit 3bf2bb0

Browse files
clydinKeen Yee Liau
authored andcommitted
refactor(@angular-devkit/build-angular): remove unused html webpack plugins
1 parent 64d1524 commit 3bf2bb0

File tree

8 files changed

+1294
-465
lines changed

8 files changed

+1294
-465
lines changed

packages/angular_devkit/build_angular/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"copy-webpack-plugin": "4.5.2",
1919
"file-loader": "2.0.0",
2020
"glob": "7.1.3",
21-
"html-webpack-plugin": "3.2.0",
2221
"istanbul": "0.4.5",
2322
"istanbul-instrumenter-loader": "3.0.1",
2423
"karma-source-map-support": "1.3.0",

packages/angular_devkit/build_angular/src/angular-cli-files/lib/base-href-webpack/base-href-webpack-plugin.ts

Lines changed: 0 additions & 49 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/angular-cli-files/lib/base-href-webpack/base-href-webpack-plugin_spec.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/angular-cli-files/lib/base-href-webpack/index.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/browser.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
// TODO: cleanup this file, it's copied as is from Angular CLI.
1010

1111
import * as path from 'path';
12-
const HtmlWebpackPlugin = require('html-webpack-plugin');
1312
const SubresourceIntegrityPlugin = require('webpack-subresource-integrity');
1413
import { LicenseWebpackPlugin } from 'license-webpack-plugin';
15-
import { generateEntryPoints, packageChunkSort } from '../../utilities/package-chunk-sort';
16-
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
14+
import { generateEntryPoints } from '../../utilities/package-chunk-sort';
1715
import { IndexHtmlWebpackPlugin } from '../../plugins/index-html-webpack-plugin';
1816
import { WebpackConfigOptions } from '../build-options';
1917
import { normalizeExtraEntryPoints } from './utils';
@@ -26,37 +24,9 @@ import { normalizeExtraEntryPoints } from './utils';
2624
+ */
2725

2826
export function getBrowserConfig(wco: WebpackConfigOptions) {
29-
const { root, projectRoot, buildOptions } = wco;
30-
31-
27+
const { root, buildOptions } = wco;
3228
let extraPlugins: any[] = [];
3329

34-
// Figure out which are the lazy loaded bundle names.
35-
const lazyChunkBundleNames = normalizeExtraEntryPoints(
36-
// We don't really need a default name because we pre-filtered by lazy only entries.
37-
[...buildOptions.styles, ...buildOptions.scripts], 'not-lazy')
38-
.filter(entry => entry.lazy)
39-
.map(entry => entry.bundleName)
40-
41-
const generateIndexHtml = false;
42-
if (generateIndexHtml) {
43-
extraPlugins.push(new HtmlWebpackPlugin({
44-
template: path.resolve(root, buildOptions.index),
45-
filename: path.resolve(buildOptions.outputPath, buildOptions.index),
46-
chunksSortMode: packageChunkSort(buildOptions),
47-
excludeChunks: lazyChunkBundleNames,
48-
xhtml: true,
49-
minify: buildOptions.optimization ? {
50-
caseSensitive: true,
51-
collapseWhitespace: true,
52-
keepClosingSlash: true
53-
} : false
54-
}));
55-
extraPlugins.push(new BaseHrefWebpackPlugin({
56-
baseHref: buildOptions.baseHref as string
57-
}));
58-
}
59-
6030
let sourcemaps: string | false = false;
6131
if (buildOptions.sourceMap) {
6232
// See https://webpack.js.org/configuration/devtool/ for sourcemap types.

packages/angular_devkit/build_angular/src/angular-cli-files/plugins/webpack.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
// Exports the webpack plugins we use internally.
10-
export { BaseHrefWebpackPlugin } from '../lib/base-href-webpack/base-href-webpack-plugin';
1110
export { CleanCssWebpackPlugin, CleanCssWebpackPluginOptions } from './cleancss-webpack-plugin';
1211
export { BundleBudgetPlugin, BundleBudgetPluginOptions } from './bundle-budget';
1312
export { ScriptsWebpackPlugin, ScriptsWebpackPluginOptions } from './scripts-webpack-plugin';

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/package-chunk-sort.ts

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
// tslint:disable
9-
// TODO: cleanup this file, it's copied as is from Angular CLI.
10-
118
import { ExtraEntryPoint } from '../../browser/schema';
129
import { normalizeExtraEntryPoints } from '../models/webpack-configs/utils';
1310

14-
export function generateEntryPoints(appConfig: any) {
15-
let entryPoints = ['polyfills', 'sw-register'];
11+
export function generateEntryPoints(
12+
appConfig: { styles: ExtraEntryPoint[], scripts: ExtraEntryPoint[] },
13+
) {
14+
const entryPoints = ['polyfills', 'sw-register'];
1615

1716
// Add all styles/scripts, except lazy-loaded ones.
1817
[
19-
...normalizeExtraEntryPoints(appConfig.styles as ExtraEntryPoint[], 'styles')
18+
...normalizeExtraEntryPoints(appConfig.styles, 'styles')
2019
.filter(entry => !entry.lazy)
2120
.map(entry => entry.bundleName),
22-
...normalizeExtraEntryPoints(appConfig.scripts as ExtraEntryPoint[], 'scripts')
21+
...normalizeExtraEntryPoints(appConfig.scripts, 'scripts')
2322
.filter(entry => !entry.lazy)
2423
.map(entry => entry.bundleName),
2524
].forEach(bundleName => {
@@ -32,27 +31,3 @@ export function generateEntryPoints(appConfig: any) {
3231

3332
return entryPoints;
3433
}
35-
36-
// Sort chunks according to a predefined order:
37-
// inline, polyfills, all styles, vendor, main
38-
export function packageChunkSort(appConfig: any) {
39-
const entryPoints = generateEntryPoints(appConfig);
40-
41-
function sort(left: any, right: any) {
42-
let leftIndex = entryPoints.indexOf(left.names[0]);
43-
let rightindex = entryPoints.indexOf(right.names[0]);
44-
45-
if (leftIndex > rightindex) {
46-
return 1;
47-
} else if (leftIndex < rightindex) {
48-
return -1;
49-
} else {
50-
return 0;
51-
}
52-
}
53-
54-
// We need to list of entry points for the Ejected webpack config to work (we reuse the function
55-
// defined above).
56-
(sort as any).entryPoints = entryPoints;
57-
return sort;
58-
}

0 commit comments

Comments
 (0)