Skip to content

Improve production build times #9295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@angular-devkit/schematics": "~0.0.51",
"@schematics/angular": "~0.1.16",
"autoprefixer": "^7.2.3",
"cache-loader": "^1.2.0",
"chalk": "~2.2.0",
"circular-dependency-plugin": "^4.2.1",
"clean-css": "^4.1.9",
Expand Down Expand Up @@ -114,8 +115,8 @@
"@types/fs-extra": "^4.0.0",
"@types/glob": "^5.0.29",
"@types/jasmine": "2.5.45",
"@types/lodash": "~4.14.50",
"@types/loader-utils": "^1.1.0",
"@types/lodash": "~4.14.50",
"@types/minimist": "^1.2.0",
"@types/mock-fs": "^3.6.30",
"@types/node": "^6.0.84",
Expand Down
12 changes: 11 additions & 1 deletion packages/@angular/cli/models/webpack-configs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ScriptsWebpackPlugin } from '../../plugins/scripts-webpack-plugin';
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const SilentError = require('silent-error');
const resolve = require('resolve');

/**
* Enumerate loaders and their dependencies from this file to let the dependency validator
Expand All @@ -20,6 +21,7 @@ const SilentError = require('silent-error');
* require('raw-loader')
* require('url-loader')
* require('file-loader')
* require('cache-loader')
* require('@angular-devkit/build-optimizer')
*/

Expand Down Expand Up @@ -163,12 +165,20 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
}

if (buildOptions.buildOptimizer) {
// Set the cache directory to the Build Optimizer dir, so that package updates will delete it.
const buildOptimizerDir = path.dirname(
resolve.sync('@angular-devkit/build-optimizer', { basedir: projectRoot }));
const cacheDirectory = path.resolve(buildOptimizerDir, './.cache/');

extraRules.push({
test: /\.js$/,
use: [{
loader: 'cache-loader',
options: { cacheDirectory }
}, {
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: { sourceMap: buildOptions.sourcemaps }
}]
}],
});
}

Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/models/webpack-configs/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export function getProdConfig(wco: WebpackConfigOptions) {
new UglifyJSPlugin({
sourceMap: buildOptions.sourcemaps,
parallel: true,
cache: true,
uglifyOptions: {
ecma: wco.supportES2015 ? 6 : 5,
warnings: buildOptions.verbose,
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@ngtools/webpack": "1.10.0-beta.1",
"@schematics/angular": "~0.1.16",
"autoprefixer": "^7.2.3",
"cache-loader": "^1.2.0",
"chalk": "~2.2.0",
"circular-dependency-plugin": "^4.2.1",
"clean-css": "^4.1.9",
Expand Down