From 3957323d4434a77fc1f2db1e9a46ab35a4398c44 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 18 Apr 2018 09:48:40 -0600 Subject: [PATCH] fix(@angular-devkit/build-angular): support some browser options in dev-server This will allow people to override some flags from a base browser target, either from the command line or from their serve directly. The options chosen are kinda arbitrary. I simply looked at what made sense. Fix angular/angular-cli#10304 --- .../build_angular/src/dev-server/index.ts | 23 +++++++++++ .../build_angular/src/dev-server/schema.json | 40 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/packages/angular_devkit/build_angular/src/dev-server/index.ts b/packages/angular_devkit/build_angular/src/dev-server/index.ts index ae3c6fb11e..50b57fea72 100644 --- a/packages/angular_devkit/build_angular/src/dev-server/index.ts +++ b/packages/angular_devkit/build_angular/src/dev-server/index.ts @@ -51,6 +51,15 @@ export interface DevServerBuilderOptions { watch: boolean; hmrWarning: boolean; servePathDefaultWarning: boolean; + + optimization: boolean; + aot: boolean; + sourceMap: boolean; + evalSourceMap: boolean; + vendorChunk: boolean; + commonChunk: boolean; + baseHref: string; + progress: boolean; } interface WebpackDevServerConfigurationOptions { @@ -425,6 +434,20 @@ export class DevServerBuilder implements Builder { const builderConfig = architect.getBuilderConfiguration( browserTargetSpec); + // Update the browser options with the same options we support in serve, if defined. + builderConfig.options = { + ...(options.optimization !== undefined ? { optimization: options.optimization } : {}), + ...(options.aot !== undefined ? { aot: options.aot } : {}), + ...(options.sourceMap !== undefined ? { sourceMap: options.sourceMap } : {}), + ...(options.evalSourceMap !== undefined ? { evalSourceMap: options.evalSourceMap } : {}), + ...(options.vendorChunk !== undefined ? { vendorChunk: options.vendorChunk } : {}), + ...(options.commonChunk !== undefined ? { commonChunk: options.commonChunk } : {}), + ...(options.baseHref !== undefined ? { baseHref: options.baseHref } : {}), + ...(options.progress !== undefined ? { progress: options.progress } : {}), + + ...builderConfig.options, + }; + return architect.getBuilderDescription(builderConfig).pipe( concatMap(browserDescription => architect.validateBuilderOptions(builderConfig, browserDescription)), diff --git a/packages/angular_devkit/build_angular/src/dev-server/schema.json b/packages/angular_devkit/build_angular/src/dev-server/schema.json index 7cff55f8a6..d803bacd08 100644 --- a/packages/angular_devkit/build_angular/src/dev-server/schema.json +++ b/packages/angular_devkit/build_angular/src/dev-server/schema.json @@ -77,6 +77,46 @@ "type": "boolean", "description": "Show a warning when deploy-url/base-href use unsupported serve path values.", "default": true + }, + "optimization": { + "type": "boolean", + "description": "Defines the optimization level of the build." + }, + "aot": { + "type": "boolean", + "description": "Build using Ahead of Time compilation." + }, + "sourceMap": { + "type": "boolean", + "description": "Output sourcemaps." + }, + "evalSourceMap": { + "type": "boolean", + "description": "Output in-file eval sourcemaps." + }, + "vendorChunk": { + "type": "boolean", + "description": "Use a separate bundle containing only vendor libraries." + }, + "commonChunk": { + "type": "boolean", + "description": "Use a separate bundle containing code used across multiple bundles." + }, + "baseHref": { + "type": "string", + "description": "Base url for the application being built." + }, + "deployUrl": { + "type": "string", + "description": "URL where files will be deployed." + }, + "verbose": { + "type": "boolean", + "description": "Adds more details to output logging." + }, + "progress": { + "type": "boolean", + "description": "Log progress to the console while building." } }, "additionalProperties": false,