Skip to content

Commit 117409a

Browse files
committed
feat(@angular/cli): use cache and parallelization for build-optimizer
1 parent 76b61f9 commit 117409a

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

package-lock.json

+54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@angular-devkit/schematics": "~0.0.51",
4747
"@schematics/angular": "~0.1.16",
4848
"autoprefixer": "^7.2.3",
49+
"cache-loader": "^1.2.0",
4950
"chalk": "~2.2.0",
5051
"circular-dependency-plugin": "^4.2.1",
5152
"clean-css": "^4.1.9",
@@ -114,8 +115,8 @@
114115
"@types/fs-extra": "^4.0.0",
115116
"@types/glob": "^5.0.29",
116117
"@types/jasmine": "2.5.45",
117-
"@types/lodash": "~4.14.50",
118118
"@types/loader-utils": "^1.1.0",
119+
"@types/lodash": "~4.14.50",
119120
"@types/minimist": "^1.2.0",
120121
"@types/mock-fs": "^3.6.30",
121122
"@types/node": "^6.0.84",

packages/@angular/cli/models/webpack-configs/common.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as webpack from 'webpack';
22
import * as path from 'path';
3+
import * as os from 'os';
34
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
45
import { NamedLazyChunksWebpackPlugin } from '../../plugins/named-lazy-chunks-webpack-plugin';
56
import { extraEntryParser, getOutputHashFormat, AssetPattern } from './utils';
@@ -11,6 +12,7 @@ import { ScriptsWebpackPlugin } from '../../plugins/scripts-webpack-plugin';
1112
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
1213
const CircularDependencyPlugin = require('circular-dependency-plugin');
1314
const SilentError = require('silent-error');
15+
const resolve = require('resolve');
1416

1517
/**
1618
* Enumerate loaders and their dependencies from this file to let the dependency validator
@@ -20,6 +22,7 @@ const SilentError = require('silent-error');
2022
* require('raw-loader')
2123
* require('url-loader')
2224
* require('file-loader')
25+
* require('cache-loader')
2326
* require('@angular-devkit/build-optimizer')
2427
*/
2528

@@ -163,12 +166,20 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
163166
}
164167

165168
if (buildOptions.buildOptimizer) {
169+
// Set the cache directory to the Build Optimizer dir, so that package updates will delete it.
170+
const buildOptimizerDir = path.dirname(
171+
resolve.sync('@angular-devkit/build-optimizer', { basedir: projectRoot }));
172+
const cacheDirectory = path.resolve(buildOptimizerDir, './.cache/');
173+
166174
extraRules.push({
167175
test: /\.js$/,
168176
use: [{
177+
loader: 'cache-loader',
178+
options: { cacheDirectory }
179+
}, {
169180
loader: '@angular-devkit/build-optimizer/webpack-loader',
170181
options: { sourceMap: buildOptions.sourcemaps }
171-
}]
182+
}],
172183
});
173184
}
174185

packages/@angular/cli/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@ngtools/webpack": "1.10.0-beta.1",
3535
"@schematics/angular": "~0.1.16",
3636
"autoprefixer": "^7.2.3",
37+
"cache-loader": "^1.2.0",
3738
"chalk": "~2.2.0",
3839
"circular-dependency-plugin": "^4.2.1",
3940
"clean-css": "^4.1.9",

0 commit comments

Comments
 (0)