From f3cfdb803c7a17d2d18707f296e6fa51efb8a172 Mon Sep 17 00:00:00 2001 From: Blessing Pascal Date: Tue, 21 Feb 2017 13:06:23 +0100 Subject: [PATCH] Allow configuration of webpack rules --- packages/@angular/cli/lib/config/schema.json | 17 +++++++++++++++++ .../cli/models/webpack-configs/common.ts | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/@angular/cli/lib/config/schema.json b/packages/@angular/cli/lib/config/schema.json index c3c3ad42cef6..2a9ec21ed5d8 100644 --- a/packages/@angular/cli/lib/config/schema.json +++ b/packages/@angular/cli/lib/config/schema.json @@ -106,6 +106,23 @@ "type": "boolean", "default": false }, + "loaderRules": { + "description": "Array of matching rules extending the default webpack configuration.", + "type": "array", + "items": { + "type": "object", + "properties": { + "test": { + "type": "string" + }, + "loader": { + "type": "string" + } + }, + "required": ["test", "loader"], + "additionalProperties": false + } + }, "styles": { "description": "Global styles to be included in the build.", "type": "array", diff --git a/packages/@angular/cli/models/webpack-configs/common.ts b/packages/@angular/cli/models/webpack-configs/common.ts index 81829a3b3a68..773f10a9a808 100644 --- a/packages/@angular/cli/models/webpack-configs/common.ts +++ b/packages/@angular/cli/models/webpack-configs/common.ts @@ -30,7 +30,9 @@ export function getCommonConfig(wco: WebpackConfigOptions) { const nodeModules = path.resolve(projectRoot, 'node_modules'); let extraPlugins: any[] = []; - let extraRules: any[] = []; + let extraRules: any[] = appConfig.loaderRules.map((entry: any) => { + return { test: new RegExp(entry.test), loader: entry.loader }; + }) || []; let entryPoints: { [key: string]: string[] } = {}; // figure out which are the lazy loaded entry points