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