Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

Commit

Permalink
feat(@angular-devkit/build-webpack): sync changes from Angular CLI
Browse files Browse the repository at this point in the history
Contains all changes from angular/angular-cli@ca8e834...master.
  • Loading branch information
filipesilva authored and hansl committed Mar 6, 2018
1 parent 29c2646 commit 8e7658a
Show file tree
Hide file tree
Showing 54 changed files with 4,743 additions and 5,349 deletions.
7,842 changes: 3,484 additions & 4,358 deletions package-lock.json

Large diffs are not rendered by default.

59 changes: 29 additions & 30 deletions package.json
Expand Up @@ -51,21 +51,20 @@
"homepage": "https://github.com/angular/devkit",
"dependencies": {
"@angular-devkit/build-optimizer": "^0.4.2",
"@angular/common": "^5.2.1",
"@angular/compiler": "^5.2.1",
"@angular/compiler-cli": "^5.2.1",
"@angular/core": "^5.2.1",
"@angular/common": "^5.2.7",
"@angular/compiler": "^5.2.7",
"@angular/compiler-cli": "^5.2.7",
"@angular/core": "^5.2.7",
"@angular/http": "^5.2.6",
"@angular/material": "^5.2.3",
"@angular/platform-browser": "^5.2.1",
"@angular/platform-browser-dynamic": "^5.2.1",
"@angular/platform-browser": "^5.2.7",
"@angular/platform-browser-dynamic": "^5.2.7",
"@angular/router": "^5.2.6",
"@angular/service-worker": "^5.2.1",
"@angular/service-worker": "^5.2.7",
"@ngtools/json-schema": "^1.0.9",
"@ngtools/webpack": "angular/ngtools-webpack-builds#5474750",
"@ngtools/webpack": "6.0.0-beta.4",
"@types/common-tags": "^1.4.0",
"@types/copy-webpack-plugin": "^4.0.1",
"@types/denodeify": "^1.2.31",
"@types/express": "^4.11.1",
"@types/glob": "^5.0.29",
"@types/istanbul": "^0.4.29",
Expand All @@ -76,28 +75,26 @@
"@types/request": "^2.47.0",
"@types/semver": "^5.3.30",
"@types/source-map": "0.5.2",
"@types/webpack": "^3.0.2",
"@types/webpack": "^3.8.2",
"@types/webpack-sources": "^0.1.3",
"ajv": "^5.5.1",
"autoprefixer": "^7.2.3",
"bootstrap": "^4.0.0",
"cache-loader": "^1.2.2",
"chalk": "~2.2.2",
"chokidar": "^1.7.0",
"circular-dependency-plugin": "^4.3.0",
"circular-dependency-plugin": "^4.4.0",
"clean-css": "^4.1.9",
"codelyzer": "^4.0.2",
"common-tags": "^1.5.1",
"conventional-changelog": "^1.1.0",
"copy-webpack-plugin": "^4.2.3",
"css-loader": "^0.28.7",
"denodeify": "^1.2.1",
"exports-loader": "^0.6.4",
"copy-webpack-plugin": "~4.4.2",
"express": "^4.16.2",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"extract-text-webpack-plugin": "~4.0.0-beta.0",
"file-loader": "^1.1.9",
"font-awesome": "^4.7.0",
"glob": "^7.0.3",
"html-webpack-plugin": "^2.30.1",
"html-webpack-plugin": "github:webpack-contrib/html-webpack-plugin#a8a8c2b6ea496c257fd6f501db3a06a51fa03e1e",
"husky": "^0.14.3",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.0",
Expand All @@ -112,17 +109,20 @@
"karma-source-map-support": "^1.2.0",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"license-webpack-plugin": "^1.1.1",
"license-webpack-plugin": "^1.1.2",
"loader-utils": "^1.1.0",
"lodash": "^4.17.4",
"material-design-icons": "^3.0.1",
"memory-fs": "^0.4.1",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"node-sass": "^4.7.2",
"opn": "^5.1.0",
"parse5": "^4.0.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.10",
"postcss": "^6.0.19",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.1",
"postcss-url": "^7.3.0",
"protractor": "^5.1.2",
"raw-loader": "^0.5.1",
Expand All @@ -133,25 +133,24 @@
"semver-intersect": "^1.1.2",
"silent-error": "^1.1.0",
"source-map": "^0.5.6",
"source-map-loader": "^0.2.3",
"source-map-support": "^0.5.0",
"stats-webpack-plugin": "^0.6.2",
"style-loader": "^0.19.1",
"style-loader": "^0.20.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"stylus-loader": "^3.0.2",
"tar": "^3.1.5",
"temp": "^0.8.3",
"tree-kill": "^1.2.0",
"ts-node": "^5.0.0",
"tslint": "^5.9.1",
"typescript": "~2.7.2",
"uglifyjs-webpack-plugin": "^1.1.6",
"uglifyjs-webpack-plugin": "^1.2.2",
"url-loader": "^0.6.2",
"webpack": "^3.10.0",
"webpack-dev-middleware": "^1.12.2",
"webpack-dev-server": "^2.11.0",
"webpack-merge": "^4.1.1",
"webpack-sources": "^1.0.1",
"webpack": "~4.0.0",
"webpack-dev-middleware": "^2.0.6",
"webpack-dev-server": "^3.0.1-beta.0",
"webpack-merge": "^4.1.2",
"webpack-sources": "^1.1.0",
"webpack-subresource-integrity": "^1.0.3",
"zone.js": "^0.8.19"
},
Expand Down
41 changes: 20 additions & 21 deletions packages/angular_devkit/build_webpack/package.json
Expand Up @@ -12,52 +12,51 @@
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@ngtools/webpack": "^1.10.0-rc.0",
"@ngtools/webpack": "6.0.0-beta.4",
"autoprefixer": "^7.2.3",
"cache-loader": "^1.2.0",
"chalk": "~2.2.2",
"circular-dependency-plugin": "^4.3.0",
"circular-dependency-plugin": "^4.4.0",
"clean-css": "^4.1.9",
"common-tags": "^1.5.1",
"copy-webpack-plugin": "^4.2.3",
"css-loader": "^0.28.7",
"denodeify": "^1.2.1",
"exports-loader": "^0.6.4",
"extract-text-webpack-plugin": "^3.0.2",
"copy-webpack-plugin": "^4.4.2",
"extract-text-webpack-plugin": "~4.0.0-beta.0",
"file-loader": "^1.1.5",
"glob": "^7.0.3",
"html-webpack-plugin": "^2.30.1",
"html-webpack-plugin": "github:webpack-contrib/html-webpack-plugin#a8a8c2b6ea496c257fd6f501db3a06a51fa03e1e",
"karma-source-map-support": "^1.2.0",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"license-webpack-plugin": "^1.1.1",
"license-webpack-plugin": "^1.1.2",
"lodash": "^4.17.4",
"memory-fs": "^0.4.1",
"minimatch": "^3.0.4",
"node-sass": "^4.7.2",
"parse5": "^4.0.0",
"opn": "^5.1.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.10",
"postcss-url": "^7.3.0",
"postcss": "^6.0.19",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.1",
"postcss-url": "^7.3.1",
"raw-loader": "^0.5.1",
"request": "^2.83.0",
"rxjs": "^5.5.6",
"sass-loader": "^6.0.6",
"silent-error": "^1.1.0",
"source-map-loader": "^0.2.3",
"source-map-support": "^0.5.0",
"stats-webpack-plugin": "^0.6.2",
"style-loader": "^0.19.1",
"style-loader": "^0.20.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"stylus-loader": "^3.0.2",
"tree-kill": "^1.2.0",
"uglifyjs-webpack-plugin": "^1.1.6",
"uglifyjs-webpack-plugin": "^1.2.2",
"url-loader": "^0.6.2",
"webpack": "^3.10.0",
"webpack-dev-middleware": "^1.12.2",
"webpack-dev-server": "^2.11.0",
"webpack-merge": "^4.1.1",
"webpack-sources": "^1.0.1",
"webpack": "~4.0.0",
"webpack-dev-middleware": "^2.0.6",
"webpack-dev-server": "^3.0.1-beta.0",
"webpack-merge": "^4.1.2",
"webpack-sources": "^1.1.0",
"webpack-subresource-integrity": "^1.0.3"
}
}
Expand Up @@ -29,7 +29,7 @@ export class BaseHrefWebpackPlugin {
} else {
// Replace only href attribute if exists
const modifiedBaseTag = baseTagMatches[0].replace(
/href="\S+"/i, `href="${this.options.baseHref}"`
/href="\S*?"/i, `href="${this.options.baseHref}"`
);
htmlPluginData.html = htmlPluginData.html.replace(baseTagRegex, modifiedBaseTag);
}
Expand Down
Expand Up @@ -33,7 +33,6 @@ export interface BuildOptions {
buildOptimizer?: boolean;
namedChunks?: boolean;
subresourceIntegrity?: boolean;
forceTsCommonjs?: boolean;
serviceWorker?: boolean;
skipAppShell?: boolean;
statsJson: boolean;
Expand Down
Expand Up @@ -5,12 +5,19 @@ import * as webpack from 'webpack';
import * as path from 'path';
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SubresourceIntegrityPlugin = require('webpack-subresource-integrity');

import { packageChunkSort } from '../../utilities/package-chunk-sort';
import { LicenseWebpackPlugin } from 'license-webpack-plugin';
import { generateEntryPoints, packageChunkSort } from '../../utilities/package-chunk-sort';
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
import { IndexHtmlWebpackPlugin } from '../../plugins/index-html-webpack-plugin';
import { extraEntryParser, lazyChunksFilter } from './utils';
import { WebpackConfigOptions } from '../build-options';

/**
+ * license-webpack-plugin has a peer dependency on webpack-sources, list it in a comment to
+ * let the dependency validator know it is used.
+ *
+ * require('webpack-sources')
+ */

export function getBrowserConfig(wco: WebpackConfigOptions) {
const { projectRoot, buildOptions, appConfig } = wco;
Expand All @@ -25,12 +32,23 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
...extraEntryParser(appConfig.styles, appRoot, 'styles')
]);

if (buildOptions.vendorChunk) {
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
chunks: ['main'],
minChunks: (module: any) =>
module.resource && /[\\\/]node_modules[\\\/]/.test(module.resource)
// TODO: Enable this once HtmlWebpackPlugin supports Webpack 4
const generateIndexHtml = false;
if (generateIndexHtml) {
extraPlugins.push(new HtmlWebpackPlugin({
template: path.resolve(appRoot, appConfig.index),
filename: path.resolve(buildOptions.outputPath, appConfig.index),
chunksSortMode: packageChunkSort(appConfig),
excludeChunks: lazyChunks,
xhtml: true,
minify: buildOptions.optimizationLevel === 1 ? {
caseSensitive: true,
collapseWhitespace: true,
keepClosingSlash: true
} : false
}));
extraPlugins.push(new BaseHrefWebpackPlugin({
baseHref: buildOptions.baseHref as string
}));
}

Expand All @@ -54,21 +72,24 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
}
}

if (buildOptions.commonChunk) {
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
name: 'main',
async: 'common',
children: true,
minChunks: 2
}));
}

if (buildOptions.subresourceIntegrity) {
extraPlugins.push(new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384']
}));
}

if (buildOptions.extractLicenses) {
extraPlugins.push(new LicenseWebpackPlugin({
pattern: /.*/,
suppressErrors: true,
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}));
}

const globalStylesEntries = extraEntryParser(appConfig.styles, appRoot, 'styles')
.map(style => style.entry);

return {
resolve: {
mainFields: [
Expand All @@ -79,37 +100,34 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
output: {
crossOriginLoading: buildOptions.subresourceIntegrity ? 'anonymous' : false
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(appRoot, appConfig.index),
filename: path.resolve(projectRoot, buildOptions.outputPath as any, appConfig.index),
chunksSortMode: packageChunkSort(appConfig),
excludeChunks: lazyChunks,
xhtml: true,
minify: buildOptions.optimizationLevel === 1? {
caseSensitive: true,
collapseWhitespace: true,
keepClosingSlash: true
} : false
}),
new BaseHrefWebpackPlugin({
baseHref: buildOptions.baseHref as any
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: buildOptions.commonChunk ? 'all' : 'initial',
cacheGroups: {
vendors: false,
vendor: buildOptions.vendorChunk && {
name: 'vendor',
chunks: 'initial',
test: (module: any, chunks: Array<{ name: string }>) => {
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
return /[\\/]node_modules[\\/]/.test(moduleName)
&& !chunks.some(({ name }) => name === 'polyfills'
|| globalStylesEntries.includes(name));
},
},
}
}
},
plugins: extraPlugins.concat([
new IndexHtmlWebpackPlugin({
input: path.resolve(appRoot, appConfig.index),
output: appConfig.index,
baseHref: buildOptions.baseHref,
entrypoints: generateEntryPoints(appConfig),
deployUrl: buildOptions.deployUrl,
}),
new webpack.optimize.CommonsChunkPlugin({
minChunks: Infinity,
name: 'inline'
})
].concat(extraPlugins),
node: {
fs: 'empty',
global: true,
crypto: 'empty',
tls: 'empty',
net: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
]),
node: false,
};
}

0 comments on commit 8e7658a

Please sign in to comment.