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

Commit

Permalink
fix(@angular-devkit/build-angular): support some browser options in d…
Browse files Browse the repository at this point in the history
…ev-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
  • Loading branch information
hansl committed Apr 18, 2018
1 parent 8f82969 commit d000192
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -425,6 +434,20 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
const builderConfig = architect.getBuilderConfiguration<BrowserBuilderSchema>(
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)),
Expand Down
40 changes: 40 additions & 0 deletions packages/angular_devkit/build_angular/src/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d000192

Please sign in to comment.