diff --git a/docs/documentation/build.md b/docs/documentation/build.md index d4d63bbd757b..c56fed7bc48d 100644 --- a/docs/documentation/build.md +++ b/docs/documentation/build.md @@ -93,4 +93,6 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional `--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones +`--compress` use gzip compression in production mode + `--output-hashing` define the output filename cache-busting hashing mode diff --git a/docs/documentation/serve.md b/docs/documentation/serve.md index d1b836c0c186..de1b1658e58d 100644 --- a/docs/documentation/serve.md +++ b/docs/documentation/serve.md @@ -58,4 +58,6 @@ `--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones +`--compress` use gzip compression in production mode + `--output-hashing` define the output filename cache-busting hashing mode diff --git a/packages/@angular/cli/commands/build.ts b/packages/@angular/cli/commands/build.ts index caaa241f3649..b4bce77514a5 100644 --- a/packages/@angular/cli/commands/build.ts +++ b/packages/@angular/cli/commands/build.ts @@ -24,6 +24,12 @@ export const baseBuildCommandOptions: any = [ { name: 'i18n-format', type: String }, { name: 'locale', type: String }, { name: 'extract-css', type: Boolean, aliases: ['ec'] }, + { + name: 'compress', + type: Boolean, + default: true, + description: 'use gzip compression in production mode' + }, { name: 'output-hashing', type: String, diff --git a/packages/@angular/cli/models/build-options.ts b/packages/@angular/cli/models/build-options.ts index 786f1dcdf963..5dbb10ee5e4c 100644 --- a/packages/@angular/cli/models/build-options.ts +++ b/packages/@angular/cli/models/build-options.ts @@ -13,5 +13,6 @@ export interface BuildOptions { i18nFormat?: string; locale?: string; extractCss?: boolean; + compress?: boolean; outputHashing?: string; } diff --git a/packages/@angular/cli/models/webpack-config.ts b/packages/@angular/cli/models/webpack-config.ts index 5bd771fe1e41..ef200efb60f6 100644 --- a/packages/@angular/cli/models/webpack-config.ts +++ b/packages/@angular/cli/models/webpack-config.ts @@ -81,6 +81,7 @@ export class NgCliWebpackConfig { outputHashing: 'all', sourcemap: false, extractCss: true, + compress: true, aot: true } }; diff --git a/packages/@angular/cli/models/webpack-configs/production.ts b/packages/@angular/cli/models/webpack-configs/production.ts index 055f0bdc345d..ef61cb5c1b04 100644 --- a/packages/@angular/cli/models/webpack-configs/production.ts +++ b/packages/@angular/cli/models/webpack-configs/production.ts @@ -76,12 +76,13 @@ export const getProdConfig = function (wco: WebpackConfigOptions) { compress: { screw_ie8: true, warnings: buildOptions.verbose }, sourceMap: buildOptions.sourcemap }), - new CompressionPlugin({ - asset: '[path].gz[query]', - algorithm: 'gzip', - test: /\.js$|\.html$|\.css$/, - threshold: 10240 - }) + buildOptions.compress ? + new CompressionPlugin({ + asset: '[path].gz[query]', + algorithm: 'gzip', + test: /\.js$|\.html$|\.css$/, + threshold: 10240 + }) : (): void => null ].concat(extraPlugins) }; }; diff --git a/packages/@angular/cli/tasks/serve.ts b/packages/@angular/cli/tasks/serve.ts index 287d237596cb..ba1499e554c8 100644 --- a/packages/@angular/cli/tasks/serve.ts +++ b/packages/@angular/cli/tasks/serve.ts @@ -108,7 +108,7 @@ export default Task.extend({ stats: statsConfig, inline: true, proxy: proxyConfig, - compress: serveTaskOptions.target === 'production', + compress: serveTaskOptions.target === 'production' && serveTaskOptions.compress, watchOptions: { poll: projectConfig.defaults && projectConfig.defaults.poll },