Skip to content

Commit c054c4b

Browse files
mdasberghansl
authored andcommitted
refactor(@angular-devkit/build-angular): refactor the DevServerBuilder to be extendable, so you can override the webpack configuration
1 parent 2290e10 commit c054c4b

File tree

1 file changed

+14
-4
lines changed
  • packages/angular_devkit/build_angular/src/dev-server

1 file changed

+14
-4
lines changed

packages/angular_devkit/build_angular/src/dev-server/index.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
111111
// Replace the assets in options with the normalized version.
112112
tap((assetPatternObjects => browserOptions.assets = assetPatternObjects)),
113113
concatMap(() => new Observable(obs => {
114-
const browserBuilder = new BrowserBuilder(this.context);
115-
const webpackConfig = browserBuilder.buildWebpackConfig(
116-
root, projectRoot, host, browserOptions as NormalizedBrowserBuilderSchema);
114+
const webpackConfig = this.buildWebpackConfig(root, projectRoot, host, browserOptions);
117115
const statsConfig = getWebpackStatsConfig(browserOptions.verbose);
118116

119117
let webpackDevServerConfig: WebpackDevServerConfigurationOptions;
@@ -233,6 +231,19 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
233231
})));
234232
}
235233

234+
buildWebpackConfig(
235+
root: Path,
236+
projectRoot: Path,
237+
host: virtualFs.Host<fs.Stats>,
238+
browserOptions: BrowserBuilderSchema,
239+
) {
240+
const browserBuilder = new BrowserBuilder(this.context);
241+
const webpackConfig = browserBuilder.buildWebpackConfig(
242+
root, projectRoot, host, browserOptions as NormalizedBrowserBuilderSchema);
243+
244+
return webpackConfig;
245+
}
246+
236247
private _buildServerConfig(
237248
root: Path,
238249
projectRoot: Path,
@@ -465,5 +476,4 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
465476
}
466477
}
467478

468-
469479
export default DevServerBuilder;

0 commit comments

Comments
 (0)